Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cicd test #957

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions src/main/java/io/supertokens/session/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> 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<String, String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down
Loading