From ccfa6d837b599297f25147cd75f12a465eec6946 Mon Sep 17 00:00:00 2001 From: shanggeeth Date: Thu, 19 Oct 2023 10:26:32 +0530 Subject: [PATCH] Fix test failures --- .../connector/RecoveryConfigImplTest.java | 6 +-- .../SelfRegistrationConfigImplTest.java | 6 +-- .../UserSelfRegistrationManagerTest.java | 47 +++++++++++++++++++ 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImplTest.java b/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImplTest.java index 47523dac9b..6e5ba38800 100644 --- a/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImplTest.java +++ b/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImplTest.java @@ -222,9 +222,9 @@ public void testGetDefaultPropertyValues() throws IdentityGovernanceException { String testEnableNotificationBasedPasswordRecovery = "false"; String testEnableSendOTPInEmail = "false"; - String testUseUppercaseCharactersInOTP = StringUtils.EMPTY; - String testUseLowercaseCharactersInOTP = StringUtils.EMPTY; - String testUseNumbersInOTP = StringUtils.EMPTY; + String testUseUppercaseCharactersInOTP = "true"; + String testUseLowercaseCharactersInOTP = "true"; + String testUseNumbersInOTP = "true"; String testOtpLength = "6"; String testEnableQuestionBasedPasswordRecovery = "false"; String testMinimumAnswers = "2"; diff --git a/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/SelfRegistrationConfigImplTest.java b/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/SelfRegistrationConfigImplTest.java index 706bc0a0cc..ecb25c8089 100644 --- a/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/SelfRegistrationConfigImplTest.java +++ b/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/SelfRegistrationConfigImplTest.java @@ -219,9 +219,9 @@ public void testGetDefaultPropertyValues() throws IdentityGovernanceException { String testEnableSelfSignUp = "false"; String testEnableAccountLockOnCreation = "true"; String testEnableSendOTPInEmail = "false"; - String testUseUppercaseCharactersInOTP = StringUtils.EMPTY; - String testUseLowercaseCharactersInOTP = StringUtils.EMPTY; - String testUseNumbersInOTP = StringUtils.EMPTY; + String testUseUppercaseCharactersInOTP = "true"; + String testUseLowercaseCharactersInOTP = "true"; + String testUseNumbersInOTP = "true"; String testOtpLength = "6"; String testEnableSendNotificationOnCreation = "false"; String testEnableNotificationInternallyManage = "true"; diff --git a/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/signup/UserSelfRegistrationManagerTest.java b/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/signup/UserSelfRegistrationManagerTest.java index d18ee7e959..7a294db83a 100644 --- a/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/signup/UserSelfRegistrationManagerTest.java +++ b/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/signup/UserSelfRegistrationManagerTest.java @@ -78,6 +78,11 @@ import static org.testng.Assert.assertEquals; import static org.wso2.carbon.identity.auth.attribute.handler.AuthAttributeHandlerConstants.ErrorMessages.ERROR_CODE_AUTH_ATTRIBUTE_HANDLER_NOT_FOUND; import static org.wso2.carbon.identity.recovery.IdentityRecoveryConstants.ConnectorConfig.ENABLE_SELF_SIGNUP; +import static org.wso2.carbon.identity.recovery.IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SEND_OTP_IN_EMAIL; +import static org.wso2.carbon.identity.recovery.IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_USE_LOWERCASE_CHARACTERS_IN_OTP; +import static org.wso2.carbon.identity.recovery.IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_USE_NUMBERS_IN_OTP; +import static org.wso2.carbon.identity.recovery.IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_USE_UPPERCASE_CHARACTERS_IN_OTP; +import static org.wso2.carbon.identity.recovery.IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_OTP_LENGTH; import static org.wso2.carbon.identity.recovery.IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME; import static org.wso2.carbon.identity.recovery.IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMS_OTP_REGEX; import static org.wso2.carbon.identity.recovery.IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_VERIFICATION_CODE_EXPIRY_TIME; @@ -242,6 +247,31 @@ private void mockConfigurations(String enableSelfSignUp, String enableInternalNo notificationConfig.setName(SIGN_UP_NOTIFICATION_INTERNALLY_MANAGE); notificationConfig.setValue(enableInternalNotifications); + org.wso2.carbon.identity.application.common.model.Property sendOtpInEmailConfig = + new org.wso2.carbon.identity.application.common.model.Property(); + sendOtpInEmailConfig.setName(SELF_REGISTRATION_SEND_OTP_IN_EMAIL); + sendOtpInEmailConfig.setValue("false"); + + org.wso2.carbon.identity.application.common.model.Property useLowerCaseConfig = + new org.wso2.carbon.identity.application.common.model.Property(); + useLowerCaseConfig.setName(SELF_REGISTRATION_USE_LOWERCASE_CHARACTERS_IN_OTP); + useLowerCaseConfig.setValue("true"); + + org.wso2.carbon.identity.application.common.model.Property useNumbersConfig = + new org.wso2.carbon.identity.application.common.model.Property(); + useNumbersConfig.setName(SELF_REGISTRATION_USE_NUMBERS_IN_OTP); + useNumbersConfig.setValue("true"); + + org.wso2.carbon.identity.application.common.model.Property useUpperCaseConfig = + new org.wso2.carbon.identity.application.common.model.Property(); + useUpperCaseConfig.setName(SELF_REGISTRATION_USE_UPPERCASE_CHARACTERS_IN_OTP); + useUpperCaseConfig.setValue("true"); + + org.wso2.carbon.identity.application.common.model.Property otpLengthConfig = + new org.wso2.carbon.identity.application.common.model.Property(); + otpLengthConfig.setName(SELF_REGISTRATION_OTP_LENGTH); + otpLengthConfig.setValue("6"); + org.wso2.carbon.identity.application.common.model.Property smsOTPConfig = new org.wso2.carbon.identity.application.common.model.Property(); smsOTPConfig.setName(SELF_REGISTRATION_SMS_OTP_REGEX); @@ -263,6 +293,23 @@ private void mockConfigurations(String enableSelfSignUp, String enableInternalNo when(identityGovernanceService .getConfiguration(new String[]{SIGN_UP_NOTIFICATION_INTERNALLY_MANAGE}, TEST_TENANT_DOMAIN_NAME)) .thenReturn(new org.wso2.carbon.identity.application.common.model.Property[]{notificationConfig}); + when(identityGovernanceService + .getConfiguration(new String[]{SELF_REGISTRATION_SEND_OTP_IN_EMAIL}, TEST_TENANT_DOMAIN_NAME)) + .thenReturn(new org.wso2.carbon.identity.application.common.model.Property[]{sendOtpInEmailConfig}); + when(identityGovernanceService + .getConfiguration(new String[]{SELF_REGISTRATION_USE_LOWERCASE_CHARACTERS_IN_OTP}, + TEST_TENANT_DOMAIN_NAME)) + .thenReturn(new org.wso2.carbon.identity.application.common.model.Property[]{useLowerCaseConfig}); + when(identityGovernanceService + .getConfiguration(new String[]{SELF_REGISTRATION_USE_NUMBERS_IN_OTP}, TEST_TENANT_DOMAIN_NAME)) + .thenReturn(new org.wso2.carbon.identity.application.common.model.Property[]{useNumbersConfig}); + when(identityGovernanceService + .getConfiguration(new String[]{SELF_REGISTRATION_USE_UPPERCASE_CHARACTERS_IN_OTP}, + TEST_TENANT_DOMAIN_NAME)) + .thenReturn(new org.wso2.carbon.identity.application.common.model.Property[]{useUpperCaseConfig}); + when(identityGovernanceService + .getConfiguration(new String[]{SELF_REGISTRATION_OTP_LENGTH}, TEST_TENANT_DOMAIN_NAME)) + .thenReturn(new org.wso2.carbon.identity.application.common.model.Property[]{otpLengthConfig}); when(identityGovernanceService .getConfiguration(new String[]{SELF_REGISTRATION_SMS_OTP_REGEX}, TEST_TENANT_DOMAIN_NAME)) .thenReturn(new org.wso2.carbon.identity.application.common.model.Property[]{smsOTPConfig});