use of org.apereo.cas.authentication.attribute.DefaultAttributeDefinitionStore in project cas by apereo.
the class DefaultAttributeDefinitionStoreTests method verifyBadDefinitionsResource.
@Test
public void verifyBadDefinitionsResource() throws Exception {
val file = File.createTempFile("badfile", ".json");
FileUtils.write(file, "data", StandardCharsets.UTF_8);
val store = new DefaultAttributeDefinitionStore(new FileSystemResource(file));
store.setScope("example.org");
assertTrue(store.isEmpty());
}
use of org.apereo.cas.authentication.attribute.DefaultAttributeDefinitionStore in project cas by apereo.
the class DefaultAttributeDefinitionStoreTests method verifyFormattedAttrDefn.
@Test
public void verifyFormattedAttrDefn() {
val service = CoreAuthenticationTestUtils.getRegisteredService();
val store = new DefaultAttributeDefinitionStore();
store.setScope("example.org");
val defn = DefaultAttributeDefinition.builder().key("eduPersonPrincipalName").attribute("givenName").scoped(true).patternFormat("hello,{0}").build();
store.registerAttributeDefinition(defn);
var values = store.resolveAttributeValues("eduPersonPrincipalName", CollectionUtils.wrap(CoreAuthenticationTestUtils.CONST_USERNAME), service, Map.of());
assertTrue(values.isPresent());
assertTrue(values.get().getValue().contains("hello,test@example.org"));
}
use of org.apereo.cas.authentication.attribute.DefaultAttributeDefinitionStore in project cas by apereo.
the class DefaultAttributeDefinitionStoreTests method verifyPredicateAttributeDefinitions.
@Test
public void verifyPredicateAttributeDefinitions() {
val store = new DefaultAttributeDefinitionStore();
store.setScope("example.org");
val defn = DefaultAttributeDefinition.builder().key("cn").scoped(true).build();
store.registerAttributeDefinition(defn);
assertTrue(store.locateAttributeDefinition(attributeDefinition -> attributeDefinition.equals(defn)).isPresent());
}
use of org.apereo.cas.authentication.attribute.DefaultAttributeDefinitionStore in project cas by apereo.
the class DefaultAttributeDefinitionStoreTests method verifyScriptedEmbeddedAttrDefn.
@Test
public void verifyScriptedEmbeddedAttrDefn() {
val service = CoreAuthenticationTestUtils.getRegisteredService();
val store = new DefaultAttributeDefinitionStore();
store.setScope("example.org");
val defn = DefaultAttributeDefinition.builder().key("eduPersonPrincipalName").attribute("uid").scoped(true).script("groovy { logger.info(\" name: ${attributeName}, values: ${attributeValues} \"); return ['hello', 'world'] } ").build();
store.registerAttributeDefinition(defn);
var values = store.resolveAttributeValues("eduPersonPrincipalName", CollectionUtils.wrap(CoreAuthenticationTestUtils.CONST_USERNAME), service, Map.of());
assertTrue(values.isPresent());
assertTrue(values.get().getValue().contains("hello@example.org"));
assertTrue(values.get().getValue().contains("world@example.org"));
}
use of org.apereo.cas.authentication.attribute.DefaultAttributeDefinitionStore in project cas by apereo.
the class DefaultAttributeDefinitionStoreTests method verifyExternalImport.
@Test
public void verifyExternalImport() throws Exception {
val store = new DefaultAttributeDefinitionStore(new ClassPathResource("AttributeDefns.json"));
assertFalse(store.getAttributeDefinitions().isEmpty());
assertNotNull(store.locateAttributeDefinition("eduPersonPrincipalName"));
}
Aggregations