use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class AcceptUsersAuthenticationHandlerTests method verifySupportsSpecialCharacters.
@Test
public void verifySupportsSpecialCharacters() throws Exception {
val c = new UsernamePasswordCredential();
c.setUsername("brian");
c.setPassword("t�st");
assertEquals("brian", getAuthenticationHandler().authenticate(c).getPrincipal().getId());
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class AcceptUsersAuthenticationHandlerTests method verifyFailsNullUserName.
@Test
public void verifyFailsNullUserName() {
val c = new UsernamePasswordCredential();
c.setUsername(null);
c.setPassword("user");
assertThrows(AccountNotFoundException.class, () -> getAuthenticationHandler().authenticate(c));
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class AcceptUsersAuthenticationHandlerTests method verifyAuthenticatesUserInMap.
@Test
public void verifyAuthenticatesUserInMap() {
val c = new UsernamePasswordCredential();
c.setUsername(SCOTT);
c.setPassword(RUTGERS);
try {
assertEquals(SCOTT, getAuthenticationHandler().authenticate(c).getPrincipal().getId());
} catch (final GeneralSecurityException e) {
throw new AssertionError("Authentication exception caught but it should not have been thrown.", e);
}
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class UsernamePasswordCredentialTests method verifyOperation.
@Test
public void verifyOperation() {
ApplicationContextProvider.holdApplicationContext(applicationContext);
val input = new UsernamePasswordCredential("casuser", "Mellon", StringUtils.EMPTY, Map.of());
assertTrue(input.isValid());
assertEquals(UsernamePasswordCredential.class, input.getClass());
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, "submit", mock(MappingResults.class));
input.validate(validationContext);
assertTrue(context.getMessageContext().hasErrorMessages());
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class BasicCredentialMetaDataTests method verifySerializeABasicCredentialMetaDataToJson.
@Test
public void verifySerializeABasicCredentialMetaDataToJson() throws Exception {
val credentialMetaDataWritten = new BasicCredentialMetaData(new UsernamePasswordCredential());
MAPPER.writeValue(JSON_FILE, credentialMetaDataWritten);
val credentialMetaDataRead = MAPPER.readValue(JSON_FILE, BasicCredentialMetaData.class);
assertEquals(credentialMetaDataWritten, credentialMetaDataRead);
}
Aggregations