@@ -161,6 +161,40 @@ public static List<BulkImportUser> generateBulkImportUserWithEmailPasswordAndRol
161161 return users ;
162162 }
163163
164+ public static List <BulkImportUser > generateBulkImportUserWithNoExternalIdWithRoles (int numberOfUsers , List <String > tenants , int startIndex , List <String > roles ) {
165+ List <BulkImportUser > users = new ArrayList <>();
166+ JsonParser parser = new JsonParser ();
167+
168+ for (int i = startIndex ; i < numberOfUsers + startIndex ; i ++) {
169+ String email = "user" + i + "@example.com" ;
170+ String id = "somebogus" + Utils .getUUID ();
171+ JsonObject userMetadata = parser .parse ("{\" key1\" :\" " +id +"\" ,\" key2\" :{\" key3\" :\" value3\" }}" )
172+ .getAsJsonObject ();
173+
174+ List <UserRole > userRoles = new ArrayList <>();
175+ for (String roleName : roles ) {
176+ userRoles .add (new UserRole (roleName , tenants ));
177+ }
178+
179+ List <TotpDevice > totpDevices = new ArrayList <>();
180+ totpDevices .add (new TotpDevice ("secretKey" , 30 , 1 , "deviceName" ));
181+
182+ List <LoginMethod > loginMethods = new ArrayList <>();
183+ long currentTimeMillis = System .currentTimeMillis ();
184+ loginMethods .add (new LoginMethod (tenants , "emailpassword" , true , true , currentTimeMillis , email , "$2a" ,
185+ "BCRYPT" , null , null , null , null , io .supertokens .utils .Utils .getUUID ()));
186+ loginMethods
187+ .add (new LoginMethod (tenants , "thirdparty" , true , false , currentTimeMillis , email , null , null , null ,
188+ "thirdPartyId" + i , "thirdPartyUserId" + i , null , io .supertokens .utils .Utils .getUUID ()));
189+ loginMethods .add (
190+ new LoginMethod (tenants , "passwordless" , true , false , currentTimeMillis , email , null , null , null ,
191+ null , null , null , io .supertokens .utils .Utils .getUUID ()));
192+ id = loginMethods .get (0 ).superTokensUserId ;
193+ users .add (new BulkImportUser (id , null , userMetadata , userRoles , totpDevices , loginMethods ));
194+ }
195+ return users ;
196+ }
197+
164198 public static void createTenants (Main main )
165199 throws StorageQueryException , TenantOrAppNotFoundException , InvalidProviderConfigException ,
166200 FeatureNotEnabledException , IOException , InvalidConfigException ,
@@ -244,7 +278,11 @@ public static void assertBulkImportUserAndAuthRecipeUserAreEqual(Main main, AppI
244278 }
245279 }
246280 }
247- assertEquals (bulkImportUser .externalUserId , authRecipeUser .getSupertokensOrExternalUserId ());
281+ if (bulkImportUser .externalUserId != null ) {
282+ assertEquals (bulkImportUser .externalUserId , authRecipeUser .getSupertokensOrExternalUserId ());
283+ } else {
284+ assertEquals (bulkImportUser .id , authRecipeUser .getSupertokensOrExternalUserId ());
285+ }
248286 assertEquals (bulkImportUser .id , authRecipeUser .getSupertokensUserId ());
249287 assertEquals (bulkImportUser .userMetadata ,
250288 UserMetadata .getUserMetadata (appIdentifier , storage , authRecipeUser .getSupertokensOrExternalUserId ()));
0 commit comments