Search in sources :

Example 1 with ExcludedAuthenticationHandlerAuthenticationPolicy

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));
}
Also used : lombok.val(lombok.val) ExcludedAuthenticationHandlerAuthenticationPolicy(org.apereo.cas.authentication.policy.ExcludedAuthenticationHandlerAuthenticationPolicy) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Map(java.util.Map) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Map (java.util.Map)1 lombok.val (lombok.val)1 UsernamePasswordCredential (org.apereo.cas.authentication.credential.UsernamePasswordCredential)1 ExcludedAuthenticationHandlerAuthenticationPolicy (org.apereo.cas.authentication.policy.ExcludedAuthenticationHandlerAuthenticationPolicy)1 Test (org.junit.jupiter.api.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1