Search in sources :

Example 11 with AuthenticationResult

use of org.neo4j.kernel.api.security.AuthenticationResult in project neo4j by neo4j.

the class MultiRealmAuthManagerTest method shouldFailAuthenticationIfUserIsNotFound.

@Test
public void shouldFailAuthenticationIfUserIsNotFound() throws Throwable {
    // Given
    manager.start();
    // When
    AuthSubject authSubject = manager.login(authToken("unknown", "abc123")).subject();
    AuthenticationResult result = authSubject.getAuthenticationResult();
    // Then
    assertThat(result, equalTo(AuthenticationResult.FAILURE));
    logProvider.assertExactly(error("[%s]: failed to log in: invalid principal or credentials", "unknown"));
}
Also used : AuthSubject(org.neo4j.kernel.api.security.AuthSubject) AuthenticationResult(org.neo4j.kernel.api.security.AuthenticationResult) Test(org.junit.Test)

Example 12 with AuthenticationResult

use of org.neo4j.kernel.api.security.AuthenticationResult in project neo4j by neo4j.

the class MultiRealmAuthManagerTest method shouldActivateExistingUser.

@Test
public void shouldActivateExistingUser() throws Throwable {
    // Given
    users.create(newUser("jake", "abc123", false));
    manager.start();
    userManager.suspendUser("jake");
    // When
    userManager.activateUser("jake", false);
    setMockAuthenticationStrategyResult("jake", "abc123", AuthenticationResult.SUCCESS);
    // Then
    AuthenticationResult result = manager.login(authToken("jake", "abc123")).subject().getAuthenticationResult();
    assertThat(result, equalTo(AuthenticationResult.SUCCESS));
}
Also used : AuthenticationResult(org.neo4j.kernel.api.security.AuthenticationResult) Test(org.junit.Test)

Example 13 with AuthenticationResult

use of org.neo4j.kernel.api.security.AuthenticationResult in project neo4j by neo4j.

the class MultiRealmAuthManagerTest method shouldFindAndAuthenticateUserAndReturnPasswordChangeIfRequired.

@Test
public void shouldFindAndAuthenticateUserAndReturnPasswordChangeIfRequired() throws Throwable {
    // Given
    users.create(newUser("jake", "abc123", true));
    manager.start();
    setMockAuthenticationStrategyResult("jake", "abc123", AuthenticationResult.SUCCESS);
    // When
    AuthenticationResult result = manager.login(authToken("jake", "abc123")).subject().getAuthenticationResult();
    // Then
    assertThat(result, equalTo(AuthenticationResult.PASSWORD_CHANGE_REQUIRED));
    logProvider.assertExactly(info("[jake]: logged in"));
}
Also used : AuthenticationResult(org.neo4j.kernel.api.security.AuthenticationResult) Test(org.junit.Test)

Aggregations

AuthenticationResult (org.neo4j.kernel.api.security.AuthenticationResult)13 Test (org.junit.Test)11 User (org.neo4j.kernel.impl.security.User)5 AuthSubject (org.neo4j.kernel.api.security.AuthSubject)3 DisabledAccountException (org.apache.shiro.authc.DisabledAccountException)1 ExcessiveAttemptsException (org.apache.shiro.authc.ExcessiveAttemptsException)1 IncorrectCredentialsException (org.apache.shiro.authc.IncorrectCredentialsException)1 UnknownAccountException (org.apache.shiro.authc.UnknownAccountException)1 UnsupportedTokenException (org.apache.shiro.authc.pam.UnsupportedTokenException)1 InvalidAuthTokenException (org.neo4j.kernel.api.security.exception.InvalidAuthTokenException)1