Search in sources :

Example 1 with AuthenticatorConfig

use of org.wso2.carbon.identity.application.authentication.framework.config.model.AuthenticatorConfig in project identity-outbound-auth-sms-otp by wso2-extensions.

the class SMSOTPUtilsTest method testGetSMSParameters.

@Test
public void testGetSMSParameters() {
    AuthenticatorConfig authenticatorConfig = new AuthenticatorConfig();
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put(SMSOTPConstants.IS_SMSOTP_MANDATORY, "true");
    parameters.put(SMSOTPConstants.IS_SEND_OTP_DIRECTLY_TO_MOBILE, "false");
    when(FileBasedConfigurationBuilder.getInstance()).thenReturn(fileBasedConfigurationBuilder);
    // test with empty parameters map.
    when(fileBasedConfigurationBuilder.getAuthenticatorBean(anyString())).thenReturn(null);
    Assert.assertEquals(SMSOTPUtils.getSMSParameters(), Collections.emptyMap());
    // test with non-empty parameters map.
    authenticatorConfig.setParameterMap(parameters);
    when(fileBasedConfigurationBuilder.getAuthenticatorBean(anyString())).thenReturn(authenticatorConfig);
    Assert.assertEquals(SMSOTPUtils.getSMSParameters(), parameters);
}
Also used : AuthenticatorConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.AuthenticatorConfig) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with AuthenticatorConfig

use of org.wso2.carbon.identity.application.authentication.framework.config.model.AuthenticatorConfig in project identity-outbound-auth-sms-otp by wso2-extensions.

the class SMSOTPUtilsTest method testIsSMSOTPMandatoryFromLocalFile.

@Test
public void testIsSMSOTPMandatoryFromLocalFile() throws AuthenticationFailedException {
    AuthenticationContext authenticationContext = new AuthenticationContext();
    authenticationContext.setProperty(IdentityHelperConstants.GET_PROPERTY_FROM_REGISTRY, IdentityHelperConstants.GET_PROPERTY_FROM_REGISTRY);
    authenticationContext.setProperty(SMSOTPConstants.IS_SMSOTP_MANDATORY, "true");
    authenticationContext.setTenantDomain("carbon.super");
    AuthenticatorConfig authenticatorConfig = new AuthenticatorConfig();
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put(SMSOTPConstants.IS_SMSOTP_MANDATORY, "true");
    when(FileBasedConfigurationBuilder.getInstance()).thenReturn(fileBasedConfigurationBuilder);
    authenticatorConfig.setParameterMap(parameters);
    when(fileBasedConfigurationBuilder.getAuthenticatorBean(anyString())).thenReturn(authenticatorConfig);
    Assert.assertEquals(SMSOTPUtils.isSMSOTPMandatory(authenticationContext, SMSOTPConstants.AUTHENTICATOR_NAME), 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 3 with AuthenticatorConfig

use of org.wso2.carbon.identity.application.authentication.framework.config.model.AuthenticatorConfig 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)

Aggregations

HashMap (java.util.HashMap)3 Matchers.anyString (org.mockito.Matchers.anyString)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 Test (org.testng.annotations.Test)3 AuthenticatorConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.AuthenticatorConfig)3 AuthenticationContext (org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext)2