From 1443ae5a349d3da4875f71eade148e57e07c3362 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Thu, 14 Mar 2024 09:13:26 +0530 Subject: [PATCH 1/3] fix: cicd test --- .../supertokens/test/accountlinking/api/ActiveUserTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/io/supertokens/test/accountlinking/api/ActiveUserTest.java b/src/test/java/io/supertokens/test/accountlinking/api/ActiveUserTest.java index 10c652c3c..2bc7eb759 100644 --- a/src/test/java/io/supertokens/test/accountlinking/api/ActiveUserTest.java +++ b/src/test/java/io/supertokens/test/accountlinking/api/ActiveUserTest.java @@ -156,9 +156,9 @@ public void testActiveUserIsRemovedAfterLinkingAccounts() throws Exception { WebserverAPI.getLatestCDIVersion().get(), ""); } - // we don't remove the active user for the recipe user, so it should still be 2 + // we remove the active user for the recipe user, so it should be 1 userCount = ActiveUsers.countUsersActiveSince(process.getProcess(), System.currentTimeMillis() - 10000); - assertEquals(2, userCount); + assertEquals(1, userCount); // Sign in to the accounts once again { @@ -188,7 +188,7 @@ public void testActiveUserIsRemovedAfterLinkingAccounts() throws Exception { // there should still be only one active user userCount = ActiveUsers.countUsersActiveSince(process.getProcess(), System.currentTimeMillis() - 10000); - assertEquals(2, userCount); + assertEquals(1, userCount); process.kill(); assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STOPPED)); From 6036e596de33a7ef74b9468733f99f5a4247fb9e Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Thu, 14 Mar 2024 09:39:37 +0530 Subject: [PATCH 2/3] fix: session for mongo --- .../java/io/supertokens/session/Session.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/java/io/supertokens/session/Session.java b/src/main/java/io/supertokens/session/Session.java index bf307be1f..a75370195 100644 --- a/src/main/java/io/supertokens/session/Session.java +++ b/src/main/java/io/supertokens/session/Session.java @@ -140,29 +140,30 @@ public static SessionInformationHolder createNewSession(TenantIdentifier tenantI sessionHandle += "_" + tenantIdentifier.getTenantId(); } - io.supertokens.pluginInterface.useridmapping.UserIdMapping userIdMapping = UserIdMapping.getUserIdMapping( - tenantIdentifier.toAppIdentifier(), storage, recipeUserId, UserIdType.EXTERNAL); - if (userIdMapping != null) { - recipeUserId = userIdMapping.superTokensUserId; - } - String primaryUserId = recipeUserId; - if (storage.getType().equals(STORAGE_TYPE.SQL)) { + + if (storage.getType() == STORAGE_TYPE.SQL) { + io.supertokens.pluginInterface.useridmapping.UserIdMapping userIdMapping = UserIdMapping.getUserIdMapping( + tenantIdentifier.toAppIdentifier(), storage, recipeUserId, UserIdType.EXTERNAL); + if (userIdMapping != null) { + recipeUserId = userIdMapping.superTokensUserId; + } + primaryUserId = StorageUtils.getAuthRecipeStorage(storage) .getPrimaryUserIdStrForUserId(tenantIdentifier.toAppIdentifier(), recipeUserId); if (primaryUserId == null) { primaryUserId = recipeUserId; } - } - HashMap userIdMappings = UserIdMapping.getUserIdMappingForSuperTokensUserIds( - tenantIdentifier.toAppIdentifier(), storage, - new ArrayList<>(Arrays.asList(primaryUserId, recipeUserId))); - if (userIdMappings.containsKey(primaryUserId)) { - primaryUserId = userIdMappings.get(primaryUserId); - } - if (userIdMappings.containsKey(recipeUserId)) { - recipeUserId = userIdMappings.get(recipeUserId); + HashMap userIdMappings = UserIdMapping.getUserIdMappingForSuperTokensUserIds( + tenantIdentifier.toAppIdentifier(), storage, + new ArrayList<>(Arrays.asList(primaryUserId, recipeUserId))); + if (userIdMappings.containsKey(primaryUserId)) { + primaryUserId = userIdMappings.get(primaryUserId); + } + if (userIdMappings.containsKey(recipeUserId)) { + recipeUserId = userIdMappings.get(recipeUserId); + } } String antiCsrfToken = enableAntiCsrf ? UUID.randomUUID().toString() : null; From cda4ebc78890a5383d30ba485086687f8c08eec0 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Thu, 14 Mar 2024 09:41:27 +0530 Subject: [PATCH 3/3] fix: test --- .../java/io/supertokens/test/multitenant/api/TestApp.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/java/io/supertokens/test/multitenant/api/TestApp.java b/src/test/java/io/supertokens/test/multitenant/api/TestApp.java index d771e708d..79a988baf 100644 --- a/src/test/java/io/supertokens/test/multitenant/api/TestApp.java +++ b/src/test/java/io/supertokens/test/multitenant/api/TestApp.java @@ -512,6 +512,10 @@ public void testDefaultRecipesEnabledWhileCreatingApp() throws Exception { @Test public void testFirstFactorsArray() throws Exception { + if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { + return; + } + JsonObject config = new JsonObject(); StorageLayer.getBaseStorage(process.getProcess()).modifyConfigToAddANewUserPoolForTesting(config, 1); @@ -741,6 +745,10 @@ public void testInvalidTypedValueInCoreConfigWhileCreatingApp() throws Exception return; } + if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { + return; + } + String[] properties = new String[]{ "access_token_validity", // long "access_token_validity", // long