Skip to content

Commit

Permalink
fix: cicd tests (#946)
Browse files Browse the repository at this point in the history
* fix: cicd tests

* fix: cicd tests

* fix: cicd tests

* fix: cicd tests

* fix: cicd tests
  • Loading branch information
sattvikc authored Mar 5, 2024
1 parent 2a4f668 commit 388d398
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/io/supertokens/storageLayer/StorageLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.supertokens.inmemorydb.Start;
import io.supertokens.output.Logging;
import io.supertokens.pluginInterface.LOG_LEVEL;
import io.supertokens.pluginInterface.STORAGE_TYPE;
import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.authRecipe.AuthRecipeStorage;
import io.supertokens.pluginInterface.emailpassword.exceptions.UnknownUserIdException;
Expand Down Expand Up @@ -461,6 +462,16 @@ public static StorageAndUserIdMapping findStorageAndUserIdMappingForUser(
AppIdentifier appIdentifier, Storage[] storages, String userId,
UserIdType userIdType) throws StorageQueryException, UnknownUserIdException {

if (storages.length == 0) {
throw new IllegalStateException("should never come here");
}

if (storages[0].getType() != STORAGE_TYPE.SQL) {
// for non sql plugin, there will be only one storage as multitenancy is not supported
assert storages.length == 1;
return new StorageAndUserIdMapping(storages[0], null);
}

if (userIdType == UserIdType.SUPERTOKENS) {
for (Storage storage : storages) {
if (((AuthRecipeStorage) storage).doesUserIdExist(appIdentifier, userId)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.supertokens.featureflag.exceptions.FeatureNotEnabledException;
import io.supertokens.multitenancy.exception.BadPermissionException;
import io.supertokens.multitenancy.exception.CannotModifyBaseConfigException;
import io.supertokens.pluginInterface.STORAGE_TYPE;
import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.StorageUtils;
import io.supertokens.pluginInterface.authRecipe.AuthRecipeUserInfo;
Expand Down Expand Up @@ -76,6 +77,14 @@ public void beforeEach() throws InterruptedException, InvalidProviderConfigExcep
process.startProcess();
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED));

if (StorageLayer.getBaseStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) {
return;
}

if (StorageLayer.isInMemDb(process.getProcess())) {
return;
}

JsonObject config = new JsonObject();
StorageLayer.getBaseStorage(process.getProcess()).modifyConfigToAddANewUserPoolForTesting(config, 1);
TestMultitenancyAPIHelper.createTenant(process.getProcess(), TenantIdentifier.BASE_TENANT, "t1", true, true,
Expand All @@ -87,6 +96,14 @@ public void beforeEach() throws InterruptedException, InvalidProviderConfigExcep

@Test
public void testThatUserMetadataIsSavedInTheStorageWhereUserExists() throws Exception {
if (StorageLayer.getBaseStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) {
return;
}

if (StorageLayer.isInMemDb(process.getProcess())) {
return;
}

TenantIdentifier t0 = new TenantIdentifier(null, null, null);
Storage t0Storage = (StorageLayer.getStorage(t0, process.getProcess()));

Expand Down Expand Up @@ -176,6 +193,14 @@ public void testThatUserMetadataIsSavedInTheStorageWhereUserExists() throws Exce

@Test
public void testThatRoleIsStoredInPublicTenantAndUserRoleMappingInTheUserTenantStorage() throws Exception {
if (StorageLayer.getBaseStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) {
return;
}

if (StorageLayer.isInMemDb(process.getProcess())) {
return;
}

TenantIdentifier t0 = new TenantIdentifier(null, null, null);
Storage t0Storage = (StorageLayer.getStorage(t0, process.getProcess()));

Expand Down Expand Up @@ -266,6 +291,14 @@ public void testThatRoleIsStoredInPublicTenantAndUserRoleMappingInTheUserTenantS

@Test
public void testEmailVerificationWithUsersOnDifferentTenantStorages() throws Exception {
if (StorageLayer.getBaseStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) {
return;
}

if (StorageLayer.isInMemDb(process.getProcess())) {
return;
}

TenantIdentifier t0 = new TenantIdentifier(null, null, null);
Storage t0Storage = (StorageLayer.getStorage(t0, process.getProcess()));

Expand Down

0 comments on commit 388d398

Please sign in to comment.