@Test
        void checkServiceAttributeFilterAllAttributesWithCachingTurnedOn() throws Throwable {
            val policy = new ReturnAllAttributeReleasePolicy();

            val attributes = new HashMap<String, List<Object>>();
            attributes.put("values", Arrays.asList(new Object[]{"v1", "v2", "v3"}));
            attributes.put("cn", Arrays.asList(new Object[]{"commonName"}));
            attributes.put("username", Arrays.asList(new Object[]{"uid"}));

            val person = mock(PersonAttributes.class);
            when(person.getName()).thenReturn("uid");
            when(person.getAttributes()).thenReturn(attributes);

            val stub = new StubPersonAttributeDao(attributes);
            stub.setId("SampleStubRepository");

            val dao = new MergingPersonAttributeDaoImpl();
            dao.setPersonAttributeDaos(List.of(stub));

            ApplicationContextProvider.registerBeanIntoApplicationContext(this.applicationContext, dao, PrincipalResolver.BEAN_NAME_ATTRIBUTE_REPOSITORY);

            val repository = new CachingPrincipalAttributesRepository(TimeUnit.MILLISECONDS.name(), 100);
            repository.setAttributeRepositoryIds(Set.of(stub.getId()));
            val principal = PrincipalFactoryUtils.newPrincipalFactory().createPrincipal("uid", Map.of("mail", List.of("final@example.com")));

            policy.setPrincipalAttributesRepository(repository);

            val context = RegisteredServiceAttributeReleasePolicyContext.builder()
                .registeredService(CoreAttributesTestUtils.getRegisteredService())
                .service(CoreAttributesTestUtils.getService())
                .applicationContext(applicationContext)
                .principal(principal)
                .build();
            val attr = policy.getAttributes(context);
            assertEquals(attributes.size() + 1, attr.size());
        }
Attribute filtering policy tests.

@author Misagh Moayyed
@since 4.0.0
core/cas-server-core-authentication-attributes/src/test/java/org/apereo/cas/services/RegisteredServiceAttributeReleasePolicyTests.java