From 0574bfe55c39055b33158415c9af5f575e646125 Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Wed, 28 Feb 2024 14:53:51 +0530 Subject: [PATCH] fix: PR changes --- .../java/io/supertokens/bulkimport/BulkImportUserUtils.java | 6 +++--- .../test/bulkimport/apis/AddBulkImportUsersTest.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/supertokens/bulkimport/BulkImportUserUtils.java b/src/main/java/io/supertokens/bulkimport/BulkImportUserUtils.java index 2d3f0003d..e94ce5883 100644 --- a/src/main/java/io/supertokens/bulkimport/BulkImportUserUtils.java +++ b/src/main/java/io/supertokens/bulkimport/BulkImportUserUtils.java @@ -70,7 +70,7 @@ public static BulkImportUser createBulkImportUserFromJSON(Main main, AppIdentifi } private static List getParsedUserRoles(JsonObject userData, String[] allUserRoles, List errors) { - JsonArray jsonUserRoles = parseAndValidateFieldType(userData, "roles", ValueType.ARRAY_OF_STRING, + JsonArray jsonUserRoles = parseAndValidateFieldType(userData, "userRoles", ValueType.ARRAY_OF_STRING, false, JsonArray.class, errors, "."); @@ -80,12 +80,12 @@ private static List getParsedUserRoles(JsonObject userData, String[] all // We already know that the jsonUserRoles is an array of non-empty strings, we will normalise each role now List userRoles = new ArrayList<>(); - jsonUserRoles.forEach(role -> validateAndNormaliseUserRole(role.getAsString(), allUserRoles, errors)); + jsonUserRoles.forEach(role -> userRoles.add(validateAndNormaliseUserRole(role.getAsString(), allUserRoles, errors))); return userRoles; } private static List getParsedTotpDevices(JsonObject userData, List errors) { - JsonArray jsonTotpDevices = parseAndValidateFieldType(userData, "totp", ValueType.ARRAY_OF_OBJECT, false, JsonArray.class, errors, "."); + JsonArray jsonTotpDevices = parseAndValidateFieldType(userData, "totpDevices", ValueType.ARRAY_OF_OBJECT, false, JsonArray.class, errors, "."); if (jsonTotpDevices == null) { return null; } diff --git a/src/test/java/io/supertokens/test/bulkimport/apis/AddBulkImportUsersTest.java b/src/test/java/io/supertokens/test/bulkimport/apis/AddBulkImportUsersTest.java index 94ce885b0..709455605 100644 --- a/src/test/java/io/supertokens/test/bulkimport/apis/AddBulkImportUsersTest.java +++ b/src/test/java/io/supertokens/test/bulkimport/apis/AddBulkImportUsersTest.java @@ -141,7 +141,7 @@ public void shouldThrow400Error() throws Exception { { try { JsonObject request = new JsonParser() - .parse("{\"users\":[{\"externalUserId\":[],\"userMetaData\":[],\"roles\":{},\"totp\":{}}]}") + .parse("{\"users\":[{\"externalUserId\":[],\"userMetaData\":[],\"userRoles\":{},\"totpDevices\":{}}]}") .getAsJsonObject(); HttpRequestForTesting.sendJsonPOSTRequest(process.getProcess(), "", "http://localhost:3567/bulk-import/users", @@ -150,12 +150,12 @@ public void shouldThrow400Error() throws Exception { String responseString = getResponseMessageFromError(e.getMessage()); assertEquals(400, e.statusCode); assertEquals(responseString, - "{\"error\":\"" + genericErrMsg + "\",\"users\":[{\"index\":0,\"errors\":[\"externalUserId should be of type string.\",\"roles should be of type array of string.\",\"totp should be of type array of object.\",\"loginMethods is required.\"]}]}"); + "{\"error\":\"" + genericErrMsg + "\",\"users\":[{\"index\":0,\"errors\":[\"externalUserId should be of type string.\",\"userRoles should be of type array of string.\",\"totpDevices should be of type array of object.\",\"loginMethods is required.\"]}]}"); } // Invalid role (does not exist) try { JsonObject request = new JsonParser() - .parse("{\"users\":[{\"roles\":[\"role5\"]}]}") + .parse("{\"users\":[{\"userRoles\":[\"role5\"]}]}") .getAsJsonObject(); HttpRequestForTesting.sendJsonPOSTRequest(process.getProcess(), "", "http://localhost:3567/bulk-import/users",