use of org.wso2.carbon.identity.application.authentication.framework.AuthenticatorFlowStatus in project identity-outbound-auth-sms-otp by wso2-extensions.
the class SMSOTPAuthenticatorTest method testProcessWithLogoutFalse.
@Test
public void testProcessWithLogoutFalse() throws Exception {
mockStatic(FederatedAuthenticatorUtil.class);
mockStatic(SMSOTPUtils.class);
mockStatic(FrameworkUtils.class);
when(context.isLogoutRequest()).thenReturn(false);
when(httpServletRequest.getParameter(SMSOTPConstants.MOBILE_NUMBER)).thenReturn("true");
context.setTenantDomain("carbon.super");
when((AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER)).thenReturn(AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier("admin"));
FederatedAuthenticatorUtil.setUsernameFromFirstStep(context);
when(SMSOTPUtils.isSMSOTPMandatory(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn(true);
when(SMSOTPUtils.getErrorPageFromXMLFile(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn(SMSOTPConstants.ERROR_PAGE);
when(SMSOTPUtils.isSendOTPDirectlyToMobile(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn(false);
when(FrameworkUtils.getQueryStringWithFrameworkContextId(context.getQueryParams(), context.getCallerSessionKey(), context.getContextIdentifier())).thenReturn(null);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
Whitebox.invokeMethod(smsotpAuthenticator, "processSMSOTPFlow", context, httpServletRequest, httpServletResponse, false, "John@carbon.super", "", "carbon.super", SMSOTPConstants.ERROR_PAGE);
verify(httpServletResponse).sendRedirect(captor.capture());
AuthenticatorFlowStatus status = spy.process(httpServletRequest, httpServletResponse, context);
Assert.assertTrue(captor.getValue().contains(SMSOTPConstants.SEND_OTP_DIRECTLY_DISABLE));
Assert.assertEquals(status, AuthenticatorFlowStatus.INCOMPLETE);
}
use of org.wso2.carbon.identity.application.authentication.framework.AuthenticatorFlowStatus in project identity-outbound-auth-sms-otp by wso2-extensions.
the class SMSOTPAuthenticatorTest method testProcessWithLogout.
@Test
public void testProcessWithLogout() throws AuthenticationFailedException, LogoutFailedException {
mockStatic(FederatedAuthenticatorUtil.class);
mockStatic(SMSOTPUtils.class);
mockStatic(FrameworkUtils.class);
when(context.isLogoutRequest()).thenReturn(false);
when(httpServletRequest.getParameter(SMSOTPConstants.CODE)).thenReturn("");
context.setTenantDomain("carbon.super");
when((AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER)).thenReturn(AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier("admin"));
FederatedAuthenticatorUtil.setUsernameFromFirstStep(context);
when(SMSOTPUtils.isSMSOTPMandatory(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn(true);
when(SMSOTPUtils.getErrorPageFromXMLFile(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn(SMSOTPConstants.ERROR_PAGE);
when(SMSOTPUtils.isSendOTPDirectlyToMobile(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn(false);
when(FrameworkUtils.getQueryStringWithFrameworkContextId(context.getQueryParams(), context.getCallerSessionKey(), context.getContextIdentifier())).thenReturn(null);
when(SMSOTPUtils.getBackupCode(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn("false");
AuthenticatorFlowStatus status = spy.process(httpServletRequest, httpServletResponse, context);
Assert.assertEquals(status, AuthenticatorFlowStatus.INCOMPLETE);
}
use of org.wso2.carbon.identity.application.authentication.framework.AuthenticatorFlowStatus in project identity-outbound-auth-sms-otp by wso2-extensions.
the class SMSOTPAuthenticatorTest method testProcessWithLogoutTrue.
@Test
public void testProcessWithLogoutTrue() throws AuthenticationFailedException, LogoutFailedException {
when(context.isLogoutRequest()).thenReturn(true);
AuthenticatorFlowStatus status = smsotpAuthenticator.process(httpServletRequest, httpServletResponse, context);
Assert.assertEquals(status, AuthenticatorFlowStatus.SUCCESS_COMPLETED);
}
Aggregations