Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [11.0.4]

- Fixes user to roles association in bulk import users when the user is not a primary user

## [11.0.3]

- Fixes BatchUpdateException checks and error handling to prevent bulk import users stuck in `PROCESSING` state
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ compileTestJava { options.encoding = "UTF-8" }
// }
//}

version = "11.0.3"
version = "11.0.4"

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/supertokens/bulkimport/BulkImport.java
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ private static Map<TenantIdentifier, Map<String, List<String>>> gatherRolesForUs
rolesToUserByTenant.put(tenantIdentifier, new HashMap<>());
}
String userIdToUse = user.externalUserId != null ?
user.externalUserId : user.primaryUserId;
user.externalUserId : user.id;
if(!rolesToUserByTenant.get(tenantIdentifier).containsKey(userIdToUse)){
rolesToUserByTenant.get(tenantIdentifier).put(userIdToUse, new ArrayList<>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,71 @@ public void shouldImportSucceedWithoutAccountLinkingEnabled() throws Exception {
}

FeatureFlagTestContent.getInstance(main).setKeyValue(FeatureFlagTestContent.ENABLED_FEATURES,
new EE_FEATURES[] { EE_FEATURES.MULTI_TENANCY});
new EE_FEATURES[]{EE_FEATURES.MULTI_TENANCY});

BulkImportTestUtils.createTenants(process);

String userJsonStr = """
{
"externalUserId":"some-text-you-like",
"userRoles":[
{
"role":"user",
"tenantIds":[
"public",
"t1"
]
}
],
"loginMethods":[
{
"tenantIds":[
"public",
"t1"
],
"isVerified":true,
"isPrimary":false,
"timeJoinedInMSSinceEpoch":1506523117518,
"recipeId":"emailpassword",
"email":"something0@testing.com",
// passwordHash is randomly generated
"passwordHash":"$argon2id$v=19$m=23298,t=5,p=12$+AlWgiuzC2vqlKrde9G0SG$PmpDeTU2e6ORbHwUMi7MOavS0M3sUJlc9rX/o+nnSxt",
"hashingAlgorithm":"argon2"
}
]
}""";

String user2JsonStr = """
{
"userRoles":[
{
"role":"user",
"tenantIds":[
"public",
"t1"
]
}
],
"loginMethods":[
{
"tenantIds":[
"public",
"t1"
],
"isVerified":true,
"isPrimary":false,
"timeJoinedInMSSinceEpoch":1506523117518,
"recipeId":"emailpassword",
"email":"something1@testing.com",
// passwordHash is randomly generated
"passwordHash":"$argon2id$v=19$m=23298,t=5,p=12$+AlWgiuzC2vqlKrde9G0SG$PmpDeTU2e6ORbHwUMi7MOavS0M3sUJlc9rX/o+nnSxt",
"hashingAlgorithm":"argon2"
}
]
}""";
// Create user roles
UserRoles.createNewRoleOrModifyItsPermissions(main, "user", null);

String userJsonStr = "{\"id\":\"random-id-lol\",\"loginMethods\":[{\"tenantIds\":[\"public\"],\"isVerified\":true,\"isPrimary\":false,\"timeJoinedInMSSinceEpoch\":1741077729471,\"recipeId\":\"emailpassword\",\"email\":\"test@sometestmail.com\",\"passwordHash\":\"$2a\",\"hashingAlgorithm\":\"BCRYPT\"}]}";
JsonObject request = new Gson().fromJson(userJsonStr, JsonObject.class);

JsonObject response = HttpRequestForTesting.sendJsonPOSTRequest(main, "",
Expand All @@ -277,6 +339,14 @@ public void shouldImportSucceedWithoutAccountLinkingEnabled() throws Exception {
assertEquals("OK", response.get("status").getAsString());
assertNotNull(response.get("user"));

request = new Gson().fromJson(user2JsonStr, JsonObject.class);
JsonObject response2 = HttpRequestForTesting.sendJsonPOSTRequest(main, "",
"http://localhost:3567/bulk-import/import",
request, 1000, 1000, null, Utils.getCdiVersionStringLatestForTests(), null);

assertEquals("OK", response.get("status").getAsString());
assertNotNull(response.get("user"));
Comment thread
tamassoltesz marked this conversation as resolved.
Outdated

process.kill();
Assert.assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STOPPED));
}
Expand Down
Loading