Search in sources :

Example 6 with UsernamePasswordCredential

use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.

the class FileAuthenticationHandlerTests method verifyAuthenticateNoFileName.

@Test
public void verifyAuthenticateNoFileName() {
    val c = new UsernamePasswordCredential();
    this.authenticationHandler = new FileAuthenticationHandler(StringUtils.EMPTY, null, null, new ClassPathResource("fff"), FileAuthenticationHandler.DEFAULT_SEPARATOR);
    c.setUsername("scott");
    c.setPassword("rutgers");
    assertThrows(PreventedException.class, () -> this.authenticationHandler.authenticate(c));
}
Also used : lombok.val(lombok.val) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.jupiter.api.Test)

Example 7 with UsernamePasswordCredential

use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.

the class FileAuthenticationHandlerTests method verifySupportsProperUserCredentials.

@Test
public void verifySupportsProperUserCredentials() throws Exception {
    val c = new UsernamePasswordCredential();
    c.setUsername("scott");
    c.setPassword("rutgers");
    assertNotNull(this.authenticationHandler.authenticate(c));
}
Also used : lombok.val(lombok.val) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Test(org.junit.jupiter.api.Test)

Example 8 with UsernamePasswordCredential

use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.

the class FileAuthenticationHandlerTests method verifyAuthenticatesUserInFileWithDefaultSeparator.

@Test
public void verifyAuthenticatesUserInFileWithDefaultSeparator() throws Exception {
    val c = new UsernamePasswordCredential();
    c.setUsername("scott");
    c.setPassword("rutgers");
    assertNotNull(this.authenticationHandler.authenticate(c));
}
Also used : lombok.val(lombok.val) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Test(org.junit.jupiter.api.Test)

Example 9 with UsernamePasswordCredential

use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.

the class FileAuthenticationHandlerTests method verifyFailsNullPassword.

@Test
public void verifyFailsNullPassword() {
    val c = new UsernamePasswordCredential();
    c.setUsername("scott");
    c.setPassword(null);
    assertThrows(FailedLoginException.class, () -> this.authenticationHandler.authenticate(c));
}
Also used : lombok.val(lombok.val) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Test(org.junit.jupiter.api.Test)

Example 10 with UsernamePasswordCredential

use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.

the class FileAuthenticationHandlerTests method verifyAuthenticatesUserInFileWithCommaSeparator.

@Test
public void verifyAuthenticatesUserInFileWithCommaSeparator() throws Exception {
    val c = new UsernamePasswordCredential();
    this.authenticationHandler = new FileAuthenticationHandler(StringUtils.EMPTY, null, null, new ClassPathResource("authentication2.txt"), ",");
    c.setUsername("scott");
    c.setPassword("rutgers");
    assertNotNull(this.authenticationHandler.authenticate(c));
}
Also used : lombok.val(lombok.val) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)111 UsernamePasswordCredential (org.apereo.cas.authentication.credential.UsernamePasswordCredential)111 Test (org.junit.jupiter.api.Test)74 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)30 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)14 SimpleTestUsernamePasswordAuthenticationHandler (org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler)12 HashMap (java.util.HashMap)8 Map (java.util.Map)8 BasicCredentialMetaData (org.apereo.cas.authentication.metadata.BasicCredentialMetaData)8 LinkedHashMap (java.util.LinkedHashMap)7 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)7 Executable (org.junit.jupiter.api.function.Executable)7 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)6 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)6 MockRequestContext (org.springframework.webflow.test.MockRequestContext)6 ArrayList (java.util.ArrayList)5 ClassPathResource (org.springframework.core.io.ClassPathResource)5 MockServletContext (org.springframework.mock.web.MockServletContext)5 FailedLoginException (javax.security.auth.login.FailedLoginException)4 SurrogateUsernamePasswordCredential (org.apereo.cas.authentication.SurrogateUsernamePasswordCredential)4