use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class AuthenticationPolicyAwareServiceTicketValidationAuthorizerTests method verifyOperationWithHandlersAndAtLeastOneCredential.
@Test
public void verifyOperationWithHandlersAndAtLeastOneCredential() {
val handlers = List.of(getTestOtpAuthenticationHandler(), getAcceptUsersAuthenticationHandler(), getSimpleTestAuthenticationHandler());
val service = CoreAuthenticationTestUtils.getService("https://example.com/high/");
val authz = getAuthorizer(new AtLeastOneCredentialValidatedAuthenticationPolicy(), handlers);
val map = (Map) Map.of(new UsernamePasswordCredential(), getAcceptUsersAuthenticationHandler(), getOtpCredential(), getTestOtpAuthenticationHandler());
val assertion = getAssertion(map);
assertDoesNotThrow(new Executable() {
@Override
public void execute() {
authz.authorize(new MockHttpServletRequest(), service, assertion);
}
});
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class UsernamePasswordCredentialTests method verifyInvalidEvent.
@Test
public void verifyInvalidEvent() {
ApplicationContextProvider.holdApplicationContext(applicationContext);
val input = new UsernamePasswordCredential(null, "Mellon", StringUtils.EMPTY, Map.of());
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val validationContext = new DefaultValidationContext(context, "whatever", mock(MappingResults.class));
input.validate(validationContext);
assertFalse(context.getMessageContext().hasErrorMessages());
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class UsernamePasswordCredentialTests method verifySetGetUsername.
@Test
public void verifySetGetUsername() {
val c = new UsernamePasswordCredential();
val userName = "test";
c.setUsername(userName);
assertEquals(userName, c.getUsername());
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class AcceptUsersAuthenticationHandlerTests method verifyFailsNullUserNameAndPassword.
@Test
public void verifyFailsNullUserNameAndPassword() {
val c = new UsernamePasswordCredential();
c.setUsername(null);
c.setPassword(null);
assertThrows(AccountNotFoundException.class, () -> getAuthenticationHandler().authenticate(c));
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class AcceptUsersAuthenticationHandlerTests method verifySupportsProperUserCredentials.
@Test
public void verifySupportsProperUserCredentials() {
val c = new UsernamePasswordCredential();
c.setUsername(SCOTT);
c.setPassword(RUTGERS);
assertTrue(getAuthenticationHandler().supports(c));
}
Aggregations