-
Notifications
You must be signed in to change notification settings - Fork 537
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -501,4 +501,76 @@ public void testDisassociateUserWithUserIdMappingAndSession() throws Exception { | |
// OK | ||
} | ||
} | ||
|
||
@Test | ||
public void testThatUserWithSameEmailCannotBeAssociatedToATenantForEp() throws Exception { | ||
if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { | ||
return; | ||
} | ||
|
||
createTenants(); | ||
JsonObject user1 = TestMultitenancyAPIHelper.epSignUp(new TenantIdentifier(null, "a1", "t1"), "[email protected]", | ||
"password", process.getProcess()); | ||
String userId1 = user1.get("id").getAsString(); | ||
|
||
TestMultitenancyAPIHelper.epSignUp(new TenantIdentifier(null, "a1", "t2"), "[email protected]", | ||
"password", process.getProcess()); | ||
|
||
JsonObject response = TestMultitenancyAPIHelper.associateUserToTenant(new TenantIdentifier(null, "a1", "t2"), userId1, process.getProcess()); | ||
assertEquals("EMAIL_ALREADY_EXISTS_ERROR", response.getAsJsonPrimitive("status").getAsString()); | ||
} | ||
|
||
@Test | ||
public void testThatUserWithSameThirdPartyInfoCannotBeAssociatedToATenantForTp() throws Exception { | ||
if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { | ||
return; | ||
} | ||
|
||
createTenants(); | ||
JsonObject user1 = TestMultitenancyAPIHelper.tpSignInUp(new TenantIdentifier(null, "a1", "t1"), "google", "google-user", "[email protected]", | ||
process.getProcess()); | ||
String userId1 = user1.get("id").getAsString(); | ||
|
||
TestMultitenancyAPIHelper.tpSignInUp(new TenantIdentifier(null, "a1", "t2"), "google", "google-user", "[email protected]", | ||
process.getProcess()); | ||
|
||
JsonObject response = TestMultitenancyAPIHelper.associateUserToTenant(new TenantIdentifier(null, "a1", "t2"), userId1, process.getProcess()); | ||
assertEquals("THIRD_PARTY_USER_ALREADY_EXISTS_ERROR", response.getAsJsonPrimitive("status").getAsString()); | ||
} | ||
|
||
@Test | ||
public void testThatUserWithSameEmailCannotBeAssociatedToATenantForPless() throws Exception { | ||
if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { | ||
return; | ||
} | ||
|
||
createTenants(); | ||
JsonObject user1 = TestMultitenancyAPIHelper.plSignInUpEmail(new TenantIdentifier(null, "a1", "t1"), "[email protected]", | ||
process.getProcess()); | ||
String userId1 = user1.get("id").getAsString(); | ||
|
||
TestMultitenancyAPIHelper.plSignInUpEmail(new TenantIdentifier(null, "a1", "t2"), "[email protected]", | ||
process.getProcess()); | ||
|
||
JsonObject response = TestMultitenancyAPIHelper.associateUserToTenant(new TenantIdentifier(null, "a1", "t2"), userId1, process.getProcess()); | ||
assertEquals("EMAIL_ALREADY_EXISTS_ERROR", response.getAsJsonPrimitive("status").getAsString()); | ||
} | ||
|
||
@Test | ||
public void testThatUserWithSamePhoneCannotBeAssociatedToATenantForPless() throws Exception { | ||
if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { | ||
return; | ||
} | ||
|
||
createTenants(); | ||
JsonObject user1 = TestMultitenancyAPIHelper.plSignInUpNumber(new TenantIdentifier(null, "a1", "t1"), "+919876543210", | ||
process.getProcess()); | ||
String userId1 = user1.get("id").getAsString(); | ||
|
||
TestMultitenancyAPIHelper.plSignInUpNumber(new TenantIdentifier(null, "a1", "t2"), "+919876543210", | ||
process.getProcess()); | ||
|
||
JsonObject response = TestMultitenancyAPIHelper.associateUserToTenant(new TenantIdentifier(null, "a1", "t2"), userId1, process.getProcess()); | ||
assertEquals("PHONE_NUMBER_ALREADY_EXISTS_ERROR", response.getAsJsonPrimitive("status").getAsString()); | ||
} | ||
} |