Skip to content

Commit

Permalink
Add unit tests for UsernameRecoveryManagerImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
KD23243 committed Sep 30, 2024
1 parent c56ac16 commit 95cf2ab
Show file tree
Hide file tree
Showing 4 changed files with 417 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2020, WSO2 LLC. (http://www.wso2.org)
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down Expand Up @@ -190,18 +190,7 @@ public UsernameRecoverDTO notify(String recoveryCode, String channelId, String t
*/
private boolean useLegacyAPIApproach(Map<String, String> properties) {

if (MapUtils.isNotEmpty(properties)) {
try {
return Boolean.parseBoolean(properties.get(IdentityRecoveryConstants.USE_LEGACY_API_PROPERTY_KEY));
} catch (NumberFormatException e) {
if (log.isDebugEnabled()) {
String message = String.format("Invalid boolean value : %s to enable legacyAPIs", properties
.get(IdentityRecoveryConstants.USE_LEGACY_API_PROPERTY_KEY));
log.debug(message);
}
}
}
return false;
return Boolean.parseBoolean(properties.get(IdentityRecoveryConstants.USE_LEGACY_API_PROPERTY_KEY));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ private void testMultipleUsersMatchingForGivenClaims() throws Exception {
IdentityEventService identityEventService = mock(IdentityEventService.class);
when(IdentityRecoveryServiceDataHolder.getInstance().getIdentityEventService()).thenReturn(identityEventService);
mockedIdentityUtil.when(() -> IdentityUtil.getProperty
(IdentityRecoveryConstants.ConnectorConfig.USERNAME_RECOVERY_SHARED_CLAIMS))
(IdentityRecoveryConstants.ConnectorConfig.USERNAME_RECOVERY_NON_UNIQUE_USERNAME))
.thenReturn("true");
ArrayList<org.wso2.carbon.user.core.common.User> list =
userAccountRecoveryManager.getUserListByClaims
Expand Down
Loading

0 comments on commit 95cf2ab

Please sign in to comment.