use of org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler in project cas by apereo.
the class CoreAuthenticationTestUtils method getAuthentication.
public static Authentication getAuthentication(final Principal principal, final Map<String, Object> attributes) {
final AuthenticationHandler handler = new SimpleTestUsernamePasswordAuthenticationHandler();
final CredentialMetaData meta = new BasicCredentialMetaData(new UsernamePasswordCredential());
return new DefaultAuthenticationBuilder(principal).addCredential(meta).addSuccess("testHandler", new DefaultHandlerResult(handler, meta)).setAttributes(attributes).build();
}
use of org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler in project cas by apereo.
the class SpnegoCredentialsToPrincipalResolverTests method verifyValidCredentials.
@Test
public void verifyValidCredentials() {
this.spnegoCredentials.setPrincipal(new DefaultPrincipalFactory().createPrincipal("test"));
assertEquals("test", this.resolver.resolve(this.spnegoCredentials, CoreAuthenticationTestUtils.getPrincipal(), new SimpleTestUsernamePasswordAuthenticationHandler()).getId());
}
use of org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler in project cas by apereo.
the class PersonDirectoryPrincipalResolverTests method verifyNullPrincipal.
@Test
public void verifyNullPrincipal() {
final PersonDirectoryPrincipalResolver resolver = new PersonDirectoryPrincipalResolver();
final Principal p = resolver.resolve(() -> null, CoreAuthenticationTestUtils.getPrincipal(), new SimpleTestUsernamePasswordAuthenticationHandler());
assertNull(p);
}
use of org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler in project cas by apereo.
the class PersonDirectoryPrincipalResolverTests method verifyChainingResolver.
@Test
public void verifyChainingResolver() {
final PersonDirectoryPrincipalResolver resolver = new PersonDirectoryPrincipalResolver();
resolver.setAttributeRepository(CoreAuthenticationTestUtils.getAttributeRepository());
final ChainingPrincipalResolver chain = new ChainingPrincipalResolver();
chain.setChain(Arrays.asList(resolver, new EchoingPrincipalResolver()));
final Principal p = chain.resolve(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword(), CoreAuthenticationTestUtils.getPrincipal(CoreAuthenticationTestUtils.CONST_USERNAME, Collections.singletonMap(ATTR_1, "value")), new SimpleTestUsernamePasswordAuthenticationHandler());
assertEquals(p.getAttributes().size(), CoreAuthenticationTestUtils.getAttributeRepository().getPossibleUserAttributeNames().size() + 1);
assertTrue(p.getAttributes().containsKey(ATTR_1));
}
use of org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler in project cas by apereo.
the class PersonDirectoryPrincipalResolverTests method verifyChainingResolverDistinct.
@Test
public void verifyChainingResolverDistinct() {
final PersonDirectoryPrincipalResolver resolver = new PersonDirectoryPrincipalResolver();
resolver.setAttributeRepository(CoreAuthenticationTestUtils.getAttributeRepository());
final ChainingPrincipalResolver chain = new ChainingPrincipalResolver();
chain.setChain(Arrays.asList(resolver, new EchoingPrincipalResolver()));
this.thrown.expect(PrincipalException.class);
chain.resolve(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword(), CoreAuthenticationTestUtils.getPrincipal("somethingelse", Collections.singletonMap(ATTR_1, "value")), new SimpleTestUsernamePasswordAuthenticationHandler());
}
Aggregations