Search in sources :

Example 6 with SMSOTPAuthenticator

use of org.wso2.carbon.identity.authenticator.smsotp.SMSOTPAuthenticator in project identity-outbound-auth-sms-otp by wso2-extensions.

the class SMSOTPAuthenticatorTest method testGetURL.

@Test
public void testGetURL() throws Exception {
    SMSOTPAuthenticator smsotp = PowerMockito.spy(smsotpAuthenticator);
    Assert.assertEquals(Whitebox.invokeMethod(smsotp, "getURL", SMSOTPConstants.LOGIN_PAGE, null), "authenticationendpoint/login.do?authenticators=SMSOTP");
}
Also used : SMSOTPAuthenticator(org.wso2.carbon.identity.authenticator.smsotp.SMSOTPAuthenticator) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 7 with SMSOTPAuthenticator

use of org.wso2.carbon.identity.authenticator.smsotp.SMSOTPAuthenticator in project identity-outbound-auth-sms-otp by wso2-extensions.

the class SMSOTPAuthenticatorTest method testGetURLwithQueryParams.

@Test
public void testGetURLwithQueryParams() throws Exception {
    SMSOTPAuthenticator smsotp = PowerMockito.spy(smsotpAuthenticator);
    Assert.assertEquals(Whitebox.invokeMethod(smsotp, "getURL", SMSOTPConstants.LOGIN_PAGE, "n=John&n=Susan"), "authenticationendpoint/login.do?n=John&n=Susan&authenticators=SMSOTP");
}
Also used : SMSOTPAuthenticator(org.wso2.carbon.identity.authenticator.smsotp.SMSOTPAuthenticator) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 8 with SMSOTPAuthenticator

use of org.wso2.carbon.identity.authenticator.smsotp.SMSOTPAuthenticator in project identity-outbound-auth-sms-otp by wso2-extensions.

the class SMSOTPAuthenticatorTest method testRedirectToMobileNumberReqPage.

@Test
public void testRedirectToMobileNumberReqPage() throws Exception {
    mockStatic(SMSOTPUtils.class);
    AuthenticationContext authenticationContext = new AuthenticationContext();
    when(SMSOTPUtils.isEnableMobileNoUpdate(authenticationContext, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn(true);
    when(SMSOTPUtils.getMobileNumberRequestPage(authenticationContext, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn("/smsotpauthenticationendpoint/mobile.jsp");
    ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
    Whitebox.invokeMethod(smsotpAuthenticator, "redirectToMobileNoReqPage", httpServletResponse, authenticationContext, null);
    verify(httpServletResponse).sendRedirect(captor.capture());
    Assert.assertTrue(captor.getValue().contains(SMSOTPConstants.AUTHENTICATOR_NAME));
}
Also used : AuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 9 with SMSOTPAuthenticator

use of org.wso2.carbon.identity.authenticator.smsotp.SMSOTPAuthenticator in project identity-outbound-auth-sms-otp by wso2-extensions.

the class SMSOTPAuthenticatorTest method testRedirectToErrorPage.

@Test
public void testRedirectToErrorPage() throws Exception {
    mockStatic(SMSOTPUtils.class);
    AuthenticationContext authenticationContext = new AuthenticationContext();
    when(SMSOTPUtils.getErrorPageFromXMLFile(authenticationContext, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn("/smsotpauthenticationendpoint/smsotpError.jsp");
    ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
    Whitebox.invokeMethod(smsotpAuthenticator, "redirectToErrorPage", httpServletResponse, authenticationContext, null, null);
    verify(httpServletResponse).sendRedirect(captor.capture());
    Assert.assertTrue(captor.getValue().contains(SMSOTPConstants.AUTHENTICATOR_NAME));
}
Also used : AuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 10 with SMSOTPAuthenticator

use of org.wso2.carbon.identity.authenticator.smsotp.SMSOTPAuthenticator in project identity-outbound-auth-sms-otp by wso2-extensions.

the class SMSOTPAuthenticatorTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    smsotpAuthenticator = new SMSOTPAuthenticator();
    initMocks(this);
}
Also used : SMSOTPAuthenticator(org.wso2.carbon.identity.authenticator.smsotp.SMSOTPAuthenticator) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 Test (org.testng.annotations.Test)8 SMSOTPAuthenticator (org.wso2.carbon.identity.authenticator.smsotp.SMSOTPAuthenticator)5 Matchers.anyString (org.mockito.Matchers.anyString)3 AuthenticatedUser (org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser)3 AuthenticationContext (org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext)2 Hashtable (java.util.Hashtable)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 ApplicationAuthenticator (org.wso2.carbon.identity.application.authentication.framework.ApplicationAuthenticator)1 AuthenticatorFlowStatus (org.wso2.carbon.identity.application.authentication.framework.AuthenticatorFlowStatus)1