package org.apereo.cas.support.saml.services;

import org.apereo.cas.authentication.CoreAuthenticationTestUtils;
import org.apereo.cas.category.FileSystemCategory;
import org.apereo.cas.support.saml.BaseSamlIdPConfigurationTests;
import org.apereo.cas.support.saml.SamlIdPTestUtils;
import org.apereo.cas.util.CollectionUtils;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import java.util.Map;

import static org.junit.Assert.*;

/**
 * This is {@link GroovySamlRegisteredServiceAttributeReleasePolicyTests}.
 *
 * @author Misagh Moayyed
 * @since 5.3.0
 */
@Category(FileSystemCategory.class)
public class GroovySamlRegisteredServiceAttributeReleasePolicyTests extends BaseSamlIdPConfigurationTests {

    @Test
    public void verifyScriptReleasesSamlAttributes() {
        final GroovySamlRegisteredServiceAttributeReleasePolicy filter = new GroovySamlRegisteredServiceAttributeReleasePolicy();
        filter.setGroovyScript("classpath:saml-groovy-attrs.groovy");
        filter.setAllowedAttributes(CollectionUtils.wrapList("uid", "givenName", "displayName"));
        final SamlRegisteredService registeredService = SamlIdPTestUtils.getSamlRegisteredService();
        registeredService.setAttributeReleasePolicy(filter);
        final Map attributes = filter.getAttributes(CoreAuthenticationTestUtils.getPrincipal(),
            CoreAuthenticationTestUtils.getService(), registeredService);
        assertFalse(attributes.isEmpty());
    }

}

@@ -40,16 +40,56 @@
 vices;%0A%0A
+import org.apache.commons.io.FileUtils;%0A
 import o
@@ -138,32 +138,32 @@
 ationTestUtils;%0A
-
 import org.apere
@@ -356,24 +356,54 @@
 ctionUtils;%0A
+import org.junit.BeforeClass;%0A
 import org.j
@@ -463,16 +463,71 @@
 ategory;
+%0Aimport org.springframework.core.io.FileSystemResource;
 %0A%0Aimport
@@ -742,16 +742,16 @@
 .class)%0A
-
 public c
@@ -851,16 +851,162 @@
 ests %7B%0A%0A
+    @BeforeClass%0A    public static void beforeClass() %7B%0A        METADATA_DIRECTORY = new FileSystemResource(FileUtils.getTempDirectory());%0A    %7D%0A%0A
     @Tes

fix filesys tests for saml metadata