Skip to content

Commit

Permalink
Add connector config update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PasinduYeshan committed Sep 18, 2024
1 parent a81c82e commit d6a5683
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public class UserClaimUpdateConfigImpl implements IdentityConnectorConfig {
private static final String VERIFICATION_ON_UPDATE_ELEMENT = "VerificationOnUpdate";
private static final String NOTIFICATION_ON_UPDATE_ELEMENT = "NotificationOnUpdate";
private static final String ENABLE_MOBILE_VERIFICATION_PRIVILEGED_USER = "EnableVerificationByPrivilegedUser";
private static final String ENABLE_MULTIPLE_EMAILS_AND_MOBILE_NUMBERS_ELEMENT = "EnableMultipleEmailsAndMobileNumbers";
private static String enableEmailVerificationOnUpdateProperty = null;
private static String enableSendOTPInEmailProperty = null;
private static String useUppercaseCharactersInOTPProperty = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.axiom.om.OMElement;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
Expand All @@ -29,6 +30,7 @@
import org.wso2.carbon.identity.core.util.IdentityCoreConstants;
import org.wso2.carbon.identity.governance.IdentityGovernanceException;
import org.wso2.carbon.identity.recovery.IdentityRecoveryConstants;
import org.wso2.carbon.identity.application.common.model.Property;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -259,4 +261,11 @@ public void testGetDefaultProperties() throws IdentityGovernanceException {
assertEquals(defaultPropertyValues.size(), propertyNames.length - 1, "Maps are not equal as" +
" their size differs.");
}

@Test
public void testGetMetaData() {

Map<String, Property> metaData = userClaimUpdateConfig.getMetaData();
Assert.assertEquals(metaData.size(), 10);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,24 @@ public void testAddNewMobileToVerifiedList() throws Exception {
} catch (Exception e) {
Assert.assertTrue(e instanceof IdentityEventClientException);
}

// Case 3: Added new number is existing primary mobile number.
String newVerifiedMobileNumbers3 = existingNumber1 + "," + newMobileNumber;
Event event3 = createEvent(IdentityEventConstants.Event.PRE_SET_USER_CLAIMS,
IdentityRecoveryConstants.FALSE,
newVerifiedMobileNumbers3, null, null);

mockExistingVerifiedNumbersList(new ArrayList<>(Arrays.asList(existingNumber1)));
mockExistingNumbersList(new ArrayList<>(Arrays.asList(existingNumber1)));
mockExistingPrimaryMobileNumber(newMobileNumber);

mobileNumberVerificationHandler.handleEvent(event3);

Map<String, String> userClaims3 = getUserClaimsFromEvent(event3);
Assert.assertTrue(
StringUtils.contains(userClaims3.get(IdentityRecoveryConstants.MOBILE_NUMBERS_CLAIM), newMobileNumber));
Assert.assertTrue(StringUtils.contains(userClaims3.get(IdentityRecoveryConstants.VERIFIED_MOBILE_NUMBERS_CLAIM),
newMobileNumber));
}

@Test(description = "POST_SET_USER_CLAIMS: Verification enabled, Multi-attribute enabled")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ public void testHandleEventPostAddUserVerifyEmailClaim() throws IdentityEventExc
any()));
}

@Test(priority = 99)
@Test
public void testHandleEventPostAddUserAskPasswordClaimNotificationInternallyManaged()
throws IdentityEventException, IdentityRecoveryException {

Expand All @@ -528,7 +528,7 @@ public void testHandleEventPostAddUserAskPasswordClaimNotificationInternallyMana
any()));
}

@Test(priority = 100)
@Test
public void testHandleEventPostAddUserAskPasswordClaimNotificationExternallyManaged()
throws IdentityEventException, IdentityRecoveryException {

Expand Down

0 comments on commit d6a5683

Please sign in to comment.