use of com.nike.cerberus.auth.connector.AuthStatus in project cerberus by Nike-Inc.
the class AbstractOktaStateHandlerTest method handleSuccess.
@Test
public void handleSuccess() throws Exception {
String email = "email";
String id = "id";
AuthStatus status = AuthStatus.SUCCESS;
AuthenticationResponse expectedResponse = mock(AuthenticationResponse.class);
User user = mock(User.class);
when(user.getId()).thenReturn(id);
when(user.getLogin()).thenReturn(email);
when(expectedResponse.getUser()).thenReturn(user);
// do the call
abstractOktaStateHandler.handleSuccess(expectedResponse);
AuthResponse actualResponse = authenticationResponseFuture.get(1, TimeUnit.SECONDS);
// verify results
Assert.assertEquals(id, actualResponse.getData().getUserId());
Assert.assertEquals(email, actualResponse.getData().getUsername());
Assert.assertEquals(status, actualResponse.getStatus());
}
use of com.nike.cerberus.auth.connector.AuthStatus in project cerberus by Nike-Inc.
the class InitialLoginStateHandlerTest method handleMfaEnroll.
@Test
public void handleMfaEnroll() throws Exception {
String email = "email";
String id = "id";
AuthStatus expectedStatus = AuthStatus.MFA_REQUIRED;
FactorProvider provider = FactorProvider.OKTA;
FactorType type = FactorType.TOKEN_SOFTWARE_TOTP;
String deviceId = "device id";
String status = "status";
AuthenticationResponse expectedResponse = mock(AuthenticationResponse.class);
User user = mock(User.class);
when(user.getId()).thenReturn(id);
when(user.getLogin()).thenReturn(email);
when(expectedResponse.getUser()).thenReturn(user);
DefaultFactor factor = mock(DefaultFactor.class);
when(factor.getType()).thenReturn(type);
when(factor.getProvider()).thenReturn(provider);
when(factor.getStatus()).thenReturn(status);
when(factor.getId()).thenReturn(deviceId);
when(expectedResponse.getFactors()).thenReturn(Lists.newArrayList(factor));
// do the call
initialLoginStateHandler.handleMfaEnroll(expectedResponse);
AuthResponse actualResponse = authenticationResponseFuture.get(1, TimeUnit.SECONDS);
// verify results
assertEquals(id, actualResponse.getData().getUserId());
assertEquals(email, actualResponse.getData().getUsername());
assertEquals(expectedStatus, actualResponse.getStatus());
}
use of com.nike.cerberus.auth.connector.AuthStatus in project cerberus by Nike-Inc.
the class InitialLoginStateHandlerTest method handleMfaEnrollFails.
@Test(expected = ApiException.class)
public void handleMfaEnrollFails() throws Exception {
String email = "email";
String id = "id";
AuthStatus expectedStatus = AuthStatus.MFA_REQUIRED;
AuthenticationResponse expectedResponse = mock(AuthenticationResponse.class);
User user = mock(User.class);
when(user.getId()).thenReturn(id);
when(user.getLogin()).thenReturn(email);
when(expectedResponse.getUser()).thenReturn(user);
// do the call
initialLoginStateHandler.handleMfaEnroll(expectedResponse);
AuthResponse actualResponse = authenticationResponseFuture.get(1, TimeUnit.SECONDS);
// verify results
assertEquals(id, actualResponse.getData().getUserId());
assertEquals(email, actualResponse.getData().getUsername());
assertEquals(expectedStatus, actualResponse.getStatus());
}
use of com.nike.cerberus.auth.connector.AuthStatus in project cerberus by Nike-Inc.
the class MfaStateHandlerTest method handleMfaChallenge.
// ///////////////////////
// Test Methods
// ///////////////////////
@Test
public void handleMfaChallenge() throws Exception {
String email = "email";
String id = "id";
AuthStatus status = AuthStatus.MFA_CHALLENGE;
AuthenticationResponse expectedResponse = mock(AuthenticationResponse.class);
User user = mock(User.class);
when(user.getId()).thenReturn(id);
when(user.getLogin()).thenReturn(email);
when(expectedResponse.getUser()).thenReturn(user);
// do the call
mfaStateHandler.handleMfaChallenge(expectedResponse);
AuthResponse actualResponse = authenticationResponseFuture.get(1, TimeUnit.SECONDS);
// verify results
assertEquals(id, actualResponse.getData().getUserId());
assertEquals(email, actualResponse.getData().getUsername());
assertEquals(status, actualResponse.getStatus());
}
use of com.nike.cerberus.auth.connector.AuthStatus in project cerberus by Nike-Inc.
the class PushStateHandlerTest method handleMfaChallengeHappy.
@Test
public void handleMfaChallengeHappy() throws InterruptedException, ExecutionException, TimeoutException {
String email = "email";
String id = "id";
AuthStatus status = AuthStatus.MFA_CHALLENGE;
AuthenticationResponse expectedResponse = mock(AuthenticationResponse.class);
User user = mock(User.class);
when(user.getId()).thenReturn(id);
when(user.getLogin()).thenReturn(email);
when(expectedResponse.getUser()).thenReturn(user);
when(expectedResponse.getStatus()).thenReturn(AuthenticationStatus.MFA_CHALLENGE);
// do the call
pushStateHandler.handleMfaChallenge(expectedResponse);
AuthResponse actualResponse = authenticationResponseFuture.get(1, TimeUnit.SECONDS);
// verify results
assertEquals(id, actualResponse.getData().getUserId());
assertEquals(email, actualResponse.getData().getUsername());
assertEquals(status, actualResponse.getStatus());
}
Aggregations