Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sadilchamishka committed Oct 3, 2024
1 parent da9ce97 commit 14529e1
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.wso2.carbon.user.api.Claim;
import org.wso2.carbon.user.api.UserRealm;
import org.wso2.carbon.user.api.UserStoreManager;
import org.wso2.carbon.user.core.UserStoreException;
import org.wso2.carbon.user.core.service.RealmService;

import java.sql.Timestamp;
Expand All @@ -80,6 +81,7 @@
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.wso2.carbon.identity.auth.attribute.handler.AuthAttributeHandlerConstants.ErrorMessages.ERROR_CODE_AUTH_ATTRIBUTE_HANDLER_NOT_FOUND;
Expand Down Expand Up @@ -481,6 +483,20 @@ public void testAttributeVerificationFailures(String scenario, Property[] proper
}
}

@Test
public void registerUserInvalidOrganizationEmailDomain() {

try {
// Mock addUser to throw UserStoreException
doThrow(new UserStoreException("Simulated exception", "ORG-60091")).when(userStoreManager)
.isExistingRole(anyString());
userSelfRegistrationManager.registerUser(new User(), "", new Claim[]{}, null);
} catch (Exception e) {
// Skip the exception as the required error handling flow related code is covered.
}

}

/**
* Sample consent manager class.
*/
Expand Down

0 comments on commit 14529e1

Please sign in to comment.