use of org.apereo.cas.authentication.policy.ExcludedAuthenticationHandlerAuthenticationPolicy in project cas by apereo.
the class AuthenticationPolicyAwareServiceTicketValidationAuthorizerTests method verifyOperationWithExcludedHandlers.
@Test
public void verifyOperationWithExcludedHandlers() {
val h1 = getTestOtpAuthenticationHandler();
val h2 = getSimpleTestAuthenticationHandler();
val handlers = List.of(h1, getAcceptUsersAuthenticationHandler(), h2);
val service = CoreAuthenticationTestUtils.getService("https://example.com/high/");
val authz = getAuthorizer(new ExcludedAuthenticationHandlerAuthenticationPolicy(Set.of(h1.getName(), h2.getName()), false), handlers);
val map = (Map) Map.of(new UsernamePasswordCredential(), getAcceptUsersAuthenticationHandler(), getOtpCredential(), h1);
val assertion = getAssertion(map);
assertThrows(UnauthorizedServiceException.class, () -> authz.authorize(new MockHttpServletRequest(), service, assertion));
}
Aggregations