@Test
        void verifyAttributeFilterMappedAttributes() throws Throwable {
            val policy = new ReturnMappedAttributeReleasePolicy();
            val mappedAttr = ArrayListMultimap.<String, Object>create();
            mappedAttr.put(ATTR_1, NEW_ATTR_1_VALUE);

            policy.setAllowedAttributes(CollectionUtils.wrap(mappedAttr));
            val p = mock(Principal.class);

            val map = new HashMap<String, List<Object>>();
            map.put(ATTR_1, List.of(VALUE_1));
            map.put(ATTR_2, List.of(VALUE_2));
            map.put(ATTR_3, Arrays.asList("v3", "v4"));

            when(p.getAttributes()).thenReturn(map);
            when(p.getId()).thenReturn(PRINCIPAL_ID);

            val context = RegisteredServiceAttributeReleasePolicyContext.builder()
                .registeredService(CoreAttributesTestUtils.getRegisteredService())
                .service(CoreAttributesTestUtils.getService())
                .applicationContext(applicationContext)
                .principal(p)
                .build();
            val attr = policy.getAttributes(context);
            assertEquals(1, attr.size());
            assertTrue(attr.containsKey(NEW_ATTR_1_VALUE));

            val data = SerializationUtils.serialize(policy);
            val p2 = SerializationUtils.deserializeAndCheckObject(data, ReturnMappedAttributeReleasePolicy.class);
            assertNotNull(p2);
            assertEquals(p2.getAllowedAttributes(), policy.getAllowedAttributes());
        }
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