use of org.apereo.cas.authentication.policy.AtLeastOneCredentialValidatedAuthenticationPolicy in project cas by apereo.
the class RegisteredServiceAuthenticationPolicyResolverTests method checkDefaultPolicy.
@Test
public void checkDefaultPolicy() {
val resolver = new RegisteredServiceAuthenticationPolicyResolver(this.servicesManager, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
val transaction = new DefaultAuthenticationTransactionFactory().newTransaction(RegisteredServiceTestUtils.getService("serviceid2"), RegisteredServiceTestUtils.getCredentialsWithSameUsernameAndPassword("casuser"));
assertTrue(resolver.supports(transaction));
val policies = resolver.resolve(transaction);
assertFalse(policies.isEmpty());
assertTrue(policies.iterator().next() instanceof AtLeastOneCredentialValidatedAuthenticationPolicy);
}
use of org.apereo.cas.authentication.policy.AtLeastOneCredentialValidatedAuthenticationPolicy in project cas by apereo.
the class RegisteredServiceAuthenticationPolicyResolverTests method checkAnyPolicy.
@Test
public void checkAnyPolicy() {
val resolver = new RegisteredServiceAuthenticationPolicyResolver(this.servicesManager, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
val transaction = new DefaultAuthenticationTransactionFactory().newTransaction(RegisteredServiceTestUtils.getService("serviceid1"), RegisteredServiceTestUtils.getCredentialsWithSameUsernameAndPassword("casuser"));
val policies = resolver.resolve(transaction);
assertEquals(1, policies.size());
assertTrue(policies.iterator().next() instanceof AtLeastOneCredentialValidatedAuthenticationPolicy);
}
use of org.apereo.cas.authentication.policy.AtLeastOneCredentialValidatedAuthenticationPolicy in project cas by apereo.
the class DefaultAuthenticationManagerTests method verifyAuthenticateAnyFailureWithError.
@Test
public void verifyAuthenticateAnyFailureWithError() {
val map = new LinkedHashMap<AuthenticationHandler, PrincipalResolver>();
map.put(newMockHandler(false, true), null);
map.put(newMockHandler(false, true), null);
val authenticationExecutionPlan = getAuthenticationExecutionPlan(map);
authenticationExecutionPlan.registerAuthenticationPolicy(new AtLeastOneCredentialValidatedAuthenticationPolicy());
val manager = new DefaultAuthenticationManager(authenticationExecutionPlan, false, applicationContext);
assertThrows(AuthenticationException.class, () -> manager.authenticate(transaction));
}
use of org.apereo.cas.authentication.policy.AtLeastOneCredentialValidatedAuthenticationPolicy in project cas by apereo.
the class DefaultAuthenticationManagerTests method verifyAuthenticateAnyFailure.
@Test
public void verifyAuthenticateAnyFailure() {
val map = new LinkedHashMap<AuthenticationHandler, PrincipalResolver>();
map.put(newMockHandler(false), null);
map.put(newMockHandler(false), null);
val authenticationExecutionPlan = getAuthenticationExecutionPlan(map);
authenticationExecutionPlan.registerAuthenticationPolicy(new AtLeastOneCredentialValidatedAuthenticationPolicy());
val manager = new DefaultAuthenticationManager(authenticationExecutionPlan, false, applicationContext);
assertThrows(AuthenticationException.class, () -> manager.authenticate(transaction));
}
Aggregations