Search in sources :

Example 31 with AuthenticationFailedException

use of org.wso2.carbon.identity.application.authentication.framework.exception.AuthenticationFailedException in project identity-outbound-auth-sms-otp by wso2-extensions.

the class SMSOTPUtilsTest method testGetConfigurationFromLocalFile.

@Test
public void testGetConfigurationFromLocalFile() throws AuthenticationFailedException {
    AuthenticationContext authenticationContext = new AuthenticationContext();
    authenticationContext.setTenantDomain("carbon.super");
    authenticationContext.setProperty(IdentityHelperConstants.GET_PROPERTY_FROM_REGISTRY, IdentityHelperConstants.GET_PROPERTY_FROM_REGISTRY);
    AuthenticatorConfig authenticatorConfig = new AuthenticatorConfig();
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put(SMSOTPConstants.IS_SMSOTP_MANDATORY, "true");
    parameters.put(SMSOTPConstants.IS_ENABLED_RESEND, "true");
    when(FileBasedConfigurationBuilder.getInstance()).thenReturn(fileBasedConfigurationBuilder);
    authenticatorConfig.setParameterMap(parameters);
    when(fileBasedConfigurationBuilder.getAuthenticatorBean(anyString())).thenReturn(authenticatorConfig);
    Assert.assertEquals(SMSOTPUtils.getConfiguration(authenticationContext, SMSOTPConstants.AUTHENTICATOR_NAME, SMSOTPConstants.IS_SMSOTP_MANDATORY), "true");
}
Also used : AuthenticatorConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.AuthenticatorConfig) AuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 32 with AuthenticationFailedException

use of org.wso2.carbon.identity.application.authentication.framework.exception.AuthenticationFailedException in project identity-outbound-auth-sms-otp by wso2-extensions.

the class SMSOTPUtilsTest method testGetConfigurationFromRegistry.

@Test
public void testGetConfigurationFromRegistry() throws AuthenticationFailedException {
    AuthenticationContext authenticationContext = new AuthenticationContext();
    authenticationContext.setTenantDomain("wso2.org");
    authenticationContext.setProperty(SMSOTPConstants.IS_SMSOTP_MANDATORY, true);
    authenticationContext.setProperty("getPropertiesFromLocal", null);
    Assert.assertEquals(SMSOTPUtils.getConfiguration(authenticationContext, SMSOTPConstants.AUTHENTICATOR_NAME, SMSOTPConstants.IS_SMSOTP_MANDATORY), "true");
}
Also used : AuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 33 with AuthenticationFailedException

use of org.wso2.carbon.identity.application.authentication.framework.exception.AuthenticationFailedException in project identity-outbound-auth-sms-otp by wso2-extensions.

the class SMSOTPUtilsTest method testIsSendOTPDirectlyToMobileFromRegistry.

@Test
public void testIsSendOTPDirectlyToMobileFromRegistry() throws AuthenticationFailedException {
    AuthenticationContext authenticationContext = new AuthenticationContext();
    authenticationContext.setTenantDomain("wso2.org");
    authenticationContext.setProperty(SMSOTPConstants.IS_SEND_OTP_DIRECTLY_TO_MOBILE, "true");
    Assert.assertEquals(SMSOTPUtils.isSendOTPDirectlyToMobile(authenticationContext, SMSOTPConstants.AUTHENTICATOR_NAME), true);
}
Also used : AuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)18 Test (org.testng.annotations.Test)18 AuthenticationContext (org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext)16 AuthenticationFailedException (org.wso2.carbon.identity.application.authentication.framework.exception.AuthenticationFailedException)12 UserStoreException (org.wso2.carbon.user.api.UserStoreException)10 UserRealm (org.wso2.carbon.user.api.UserRealm)9 SMSOTPException (org.wso2.carbon.identity.authenticator.smsotp.exception.SMSOTPException)6 IOException (java.io.IOException)5 AuthenticatedUser (org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser)3 RealmService (org.wso2.carbon.user.core.service.RealmService)3 HashMap (java.util.HashMap)2 Matchers.anyString (org.mockito.Matchers.anyString)2 AuthenticatorFlowStatus (org.wso2.carbon.identity.application.authentication.framework.AuthenticatorFlowStatus)2 AuthenticatorConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.AuthenticatorConfig)2 UserStoreManager (org.wso2.carbon.user.api.UserStoreManager)2 OutputStreamWriter (java.io.OutputStreamWriter)1 MalformedURLException (java.net.MalformedURLException)1 ProtocolException (java.net.ProtocolException)1 InvalidCredentialsException (org.wso2.carbon.identity.application.authentication.framework.exception.InvalidCredentialsException)1