Search in sources :

Example 1 with MfaCheckRequest

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());
}
Also used : MfaCheckRequest(com.nike.cerberus.domain.MfaCheckRequest) AuthData(com.nike.cerberus.auth.connector.AuthData) Matchers.anyString(org.mockito.Matchers.anyString) AuthResponse(com.nike.cerberus.auth.connector.AuthResponse) Test(org.junit.Test)

Example 2 with MfaCheckRequest

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);
}
Also used : MfaCheckRequest(com.nike.cerberus.domain.MfaCheckRequest) Test(org.junit.Test)

Example 3 with 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);
}
Also used : MfaCheckRequest(com.nike.cerberus.domain.MfaCheckRequest) Test(org.junit.Test)

Example 4 with 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);
}
Also used : MfaCheckRequest(com.nike.cerberus.domain.MfaCheckRequest) Test(org.junit.Test)

Aggregations

MfaCheckRequest (com.nike.cerberus.domain.MfaCheckRequest)4 Test (org.junit.Test)4 AuthData (com.nike.cerberus.auth.connector.AuthData)1 AuthResponse (com.nike.cerberus.auth.connector.AuthResponse)1 Matchers.anyString (org.mockito.Matchers.anyString)1