use of com.nike.cerberus.domain.MfaCheckRequest in project cerberus by Nike-Inc.
the class AuthenticationServiceTest method triggerChallengeSuccess.
@Test
public void triggerChallengeSuccess() {
String stateToken = "state token";
MfaCheckRequest challengeRequest = mock(MfaCheckRequest.class);
AuthResponse expectedResponse = mock(AuthResponse.class);
AuthData expectedData = mock(AuthData.class);
when(expectedData.getStateToken()).thenReturn(stateToken);
when(expectedResponse.getData()).thenReturn(expectedData);
doAnswer(invocation -> expectedResponse).when(authConnector).triggerChallenge(any(), any());
AuthResponse actualResponse = authenticationService.triggerChallenge(challengeRequest);
assertEquals(expectedResponse, actualResponse);
assertEquals(expectedResponse.getData().getStateToken(), actualResponse.getData().getStateToken());
}
use of com.nike.cerberus.domain.MfaCheckRequest in project cerberus by Nike-Inc.
the class UserAuthenticationControllerTest method testHandleMfaCheckWhenRequestIsPush.
@Test
public void testHandleMfaCheckWhenRequestIsPush() {
MfaCheckRequest mfaCheckRequest = Mockito.mock(MfaCheckRequest.class);
Mockito.when(mfaCheckRequest.isPush()).thenReturn(true);
userAuthenticationController.handleMfaCheck(mfaCheckRequest);
Mockito.verify(authenticationService).triggerPush(mfaCheckRequest);
}
use of com.nike.cerberus.domain.MfaCheckRequest in project cerberus by Nike-Inc.
the class UserAuthenticationControllerTest method testHandleMfaCheckWhenOtpTokenIsEmpty.
@Test
public void testHandleMfaCheckWhenOtpTokenIsEmpty() {
MfaCheckRequest mfaCheckRequest = Mockito.mock(MfaCheckRequest.class);
userAuthenticationController.handleMfaCheck(mfaCheckRequest);
Mockito.verify(authenticationService, Mockito.never()).triggerPush(mfaCheckRequest);
Mockito.verify(authenticationService).triggerChallenge(mfaCheckRequest);
}
use of com.nike.cerberus.domain.MfaCheckRequest in project cerberus by Nike-Inc.
the class UserAuthenticationControllerTest method testHandleMfaCheckWhenOtpTokenIsNotEmpty.
@Test
public void testHandleMfaCheckWhenOtpTokenIsNotEmpty() {
MfaCheckRequest mfaCheckRequest = Mockito.mock(MfaCheckRequest.class);
Mockito.when(mfaCheckRequest.getOtpToken()).thenReturn("token");
userAuthenticationController.handleMfaCheck(mfaCheckRequest);
Mockito.verify(authenticationService, Mockito.never()).triggerPush(mfaCheckRequest);
Mockito.verify(authenticationService, Mockito.never()).triggerChallenge(mfaCheckRequest);
Mockito.verify(authenticationService).mfaCheck(mfaCheckRequest);
}
Aggregations