@Test
    void verifyScriptReleasesSamlAttributesWithSamlRequest() throws Throwable {
        val filter = new GroovySamlRegisteredServiceAttributeReleasePolicy();
        filter.setGroovyScript("classpath:saml-groovy-attrs.groovy");
        filter.setAllowedAttributes(CollectionUtils.wrapList("uid", "givenName", "displayName"));
        val registeredService = SamlIdPTestUtils.getSamlRegisteredService();
        registeredService.setAttributeReleasePolicy(filter);

        val request = (MockHttpServletRequest) HttpRequestUtils.getHttpServletRequestFromRequestAttributes();
        request.removeParameter(SamlProtocolConstants.PARAMETER_ENTITY_ID);

        val authnRequest = SamlIdPTestUtils.getAuthnRequest(openSamlConfigBean, registeredService);
        try (val writer = SamlUtils.transformSamlObject(openSamlConfigBean, authnRequest)) {
            val samlRequest = EncodingUtils.encodeBase64(writer.toString().getBytes(StandardCharsets.UTF_8));
            val service = RegisteredServiceTestUtils.getService();
            service.getAttributes().put(SamlProtocolConstants.PARAMETER_SAML_REQUEST, List.of(samlRequest));
            val context = RegisteredServiceAttributeReleasePolicyContext.builder()
                .registeredService(registeredService)
                .applicationContext(applicationContext)
                .service(service)
                .principal(CoreAuthenticationTestUtils.getPrincipal())
                .build();
            val attributes = filter.getAttributes(context);
            assertFalse(attributes.isEmpty());
        }
    }
This is {@link GroovySamlRegisteredServiceAttributeReleasePolicyTests}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-saml-idp/src/test/java/org/apereo/cas/support/saml/services/GroovySamlRegisteredServiceAttributeReleasePolicyTests.java