use of org.neo4j.kernel.api.security.AuthenticationResult in project neo4j by neo4j.
the class MultiRealmAuthManagerTest method shouldActivateActiveUser.
@Test
public void shouldActivateActiveUser() throws Throwable {
// Given
final User user = newUser("jake", "abc123", false);
users.create(user);
manager.start();
when(authStrategy.authenticate(user, "abc123")).thenReturn(AuthenticationResult.SUCCESS);
// 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));
}
use of org.neo4j.kernel.api.security.AuthenticationResult in project neo4j by neo4j.
the class MultiRealmAuthManagerTest method shouldReturnTooManyAttemptsWhenThatIsAppropriate.
@Test
public void shouldReturnTooManyAttemptsWhenThatIsAppropriate() throws Throwable {
// Given
users.create(newUser("jake", "abc123", true));
manager.start();
setMockAuthenticationStrategyResult("jake", "wrong password", AuthenticationResult.TOO_MANY_ATTEMPTS);
// When
AuthSubject authSubject = manager.login(authToken("jake", "wrong password")).subject();
AuthenticationResult result = authSubject.getAuthenticationResult();
// Then
assertThat(result, equalTo(AuthenticationResult.TOO_MANY_ATTEMPTS));
logProvider.assertExactly(error("[%s]: failed to log in: too many failed attempts", "jake"));
}
use of org.neo4j.kernel.api.security.AuthenticationResult in project neo4j by neo4j.
the class MultiRealmAuthManagerTest method shouldSuspendExistingUser.
@Test
public void shouldSuspendExistingUser() throws Throwable {
// Given
final User user = newUser("jake", "abc123", true);
users.create(user);
manager.start();
// When
userManager.suspendUser("jake");
// Then
setMockAuthenticationStrategyResult("jake", "abc123", AuthenticationResult.SUCCESS);
AuthenticationResult result = manager.login(authToken("jake", "abc123")).subject().getAuthenticationResult();
assertThat(result, equalTo(AuthenticationResult.FAILURE));
}
use of org.neo4j.kernel.api.security.AuthenticationResult in project neo4j by neo4j.
the class MultiRealmAuthManagerTest method shouldNotRequestPasswordChangeWithInvalidCredentials.
@Test
public void shouldNotRequestPasswordChangeWithInvalidCredentials() throws Throwable {
// Given
users.create(newUser("neo", "abc123", true));
manager.start();
setMockAuthenticationStrategyResult("neo", "abc123", AuthenticationResult.SUCCESS);
setMockAuthenticationStrategyResult("neo", "wrong", AuthenticationResult.FAILURE);
// When
AuthenticationResult result = manager.login(authToken("neo", "wrong")).subject().getAuthenticationResult();
// Then
assertThat(result, equalTo(AuthenticationResult.FAILURE));
}
use of org.neo4j.kernel.api.security.AuthenticationResult in project neo4j by neo4j.
the class MultiRealmAuthManagerTest method shouldSuspendSuspendedUser.
@Test
public void shouldSuspendSuspendedUser() throws Throwable {
// Given
final User user = newUser("jake", "abc123", false);
users.create(user);
manager.start();
userManager.suspendUser("jake");
// When
userManager.suspendUser("jake");
setMockAuthenticationStrategyResult("jake", "abc123", AuthenticationResult.SUCCESS);
// Then
AuthenticationResult result = manager.login(authToken("jake", "abc123")).subject().getAuthenticationResult();
assertThat(result, equalTo(AuthenticationResult.FAILURE));
}
Aggregations