29
29
import io .supertokens .pluginInterface .emailpassword .exceptions .DuplicatePasswordResetTokenException ;
30
30
import io .supertokens .pluginInterface .emailpassword .exceptions .DuplicateUserIdException ;
31
31
import io .supertokens .pluginInterface .emailpassword .exceptions .UnknownUserIdException ;
32
+ import io .supertokens .pluginInterface .emailpassword .sqlStorage .EmailPasswordSQLStorage ;
32
33
import io .supertokens .pluginInterface .multitenancy .AppIdentifier ;
33
34
import io .supertokens .pluginInterface .multitenancy .TenantIdentifier ;
35
+ import io .supertokens .pluginInterface .multitenancy .TenantIdentifierWithStorage ;
34
36
import io .supertokens .storageLayer .StorageLayer ;
35
37
import io .supertokens .test .TestingProcessManager ;
36
38
import io .supertokens .test .Utils ;
@@ -77,12 +79,12 @@ public void testStorageLayerGetMailPasswordStorageLayerThrowsExceptionIfTypeIsNo
77
79
78
80
if (StorageLayer .getStorage (process .getProcess ()).getType () != STORAGE_TYPE .SQL ) {
79
81
try {
80
- StorageLayer .getEmailPasswordStorage (process .getProcess ());
82
+ new TenantIdentifierWithStorage ( null , null , null , StorageLayer .getStorage (process .getProcess ())). getEmailPasswordStorage ( );
81
83
throw new Exception ("Should not come here" );
82
84
} catch (UnsupportedOperationException e ) {
83
85
}
84
86
} else {
85
- StorageLayer .getEmailPasswordStorage (process .getProcess ());
87
+ new TenantIdentifierWithStorage ( null , null , null , StorageLayer .getStorage (process .getProcess ())). getEmailPasswordStorage ( );
86
88
}
87
89
88
90
process .kill ();
@@ -169,7 +171,7 @@ public void testThatAfterSignUpThePasswordIsHashedAndStoredInTheDatabase() throw
169
171
170
172
UserInfo user =
EmailPassword .
signUp (
process .
getProcess (),
"[email protected] " ,
"validPass123" );
171
173
172
- UserInfo userInfo = StorageLayer .getEmailPasswordStorage (process .getProcess ())
174
+ UserInfo userInfo = (( EmailPasswordSQLStorage ) StorageLayer .getStorage (process .getProcess () ))
173
175
.getUserInfoUsingEmail (new TenantIdentifier (null , null , null ), user .email );
174
176
assertNotEquals (userInfo .passwordHash , "validPass123" );
175
177
assertTrue (PasswordHashing .getInstance (process .getProcess ()).verifyPasswordWithHash ("validPass123" ,
@@ -196,7 +198,7 @@ public void testThatAfterResetPasswordGenerateTokenTheTokenIsHashedInTheDatabase
196
198
UserInfo user =
EmailPassword .
signUp (
process .
getProcess (),
"[email protected] " ,
"validPass123" );
197
199
198
200
String resetToken = EmailPassword .generatePasswordResetToken (process .getProcess (), user .id );
199
- PasswordResetTokenInfo resetTokenInfo = StorageLayer .getEmailPasswordStorage (process .getProcess ())
201
+ PasswordResetTokenInfo resetTokenInfo = (( EmailPasswordSQLStorage ) StorageLayer .getStorage (process .getProcess () ))
200
202
.getPasswordResetTokenInfo (new AppIdentifier (null , null ),
201
203
io .supertokens .utils .Utils .hashSHA256 (resetToken ));
202
204
@@ -227,7 +229,7 @@ public void testThatAfterResetPasswordIsCompletedThePasswordIsHashedInTheDatabas
227
229
228
230
EmailPassword .resetPassword (process .getProcess (), resetToken , "newValidPass123" );
229
231
230
- UserInfo userInfo = StorageLayer .getEmailPasswordStorage (process .getProcess ())
232
+ UserInfo userInfo = (( EmailPasswordSQLStorage ) StorageLayer .getStorage (process .getProcess () ))
231
233
.getUserInfoUsingEmail (new TenantIdentifier (null , null , null ), user .email );
232
234
assertNotEquals (userInfo .passwordHash , "newValidPass123" );
233
235
@@ -256,7 +258,7 @@ public void passwordResetTokenExpiredCheck() throws Exception {
256
258
257
259
String tok = EmailPassword .generatePasswordResetToken (process .getProcess (), user .id );
258
260
259
- assert (StorageLayer .getEmailPasswordStorage (process .getProcess ())
261
+ assert ((( EmailPasswordSQLStorage ) StorageLayer .getStorage (process .getProcess () ))
260
262
.getAllPasswordResetTokenInfoForUser (new AppIdentifier (null , null ), user .id ).length == 1 );
261
263
262
264
Thread .sleep (20 );
@@ -268,7 +270,7 @@ public void passwordResetTokenExpiredCheck() throws Exception {
268
270
269
271
}
270
272
271
- assert (StorageLayer .getEmailPasswordStorage (process .getProcess ())
273
+ assert ((( EmailPasswordSQLStorage ) StorageLayer .getStorage (process .getProcess () ))
272
274
.getAllPasswordResetTokenInfoForUser (new AppIdentifier (null , null ), user .id ).length == 0 );
273
275
274
276
process .kill ();
@@ -292,14 +294,14 @@ public void multiplePasswordResetTokensPerUserAndThenVerifyWithSignin() throws E
292
294
String tok = EmailPassword .generatePasswordResetToken (process .getProcess (), user .id );
293
295
EmailPassword .generatePasswordResetToken (process .getProcess (), user .id );
294
296
295
- PasswordResetTokenInfo [] tokens = StorageLayer .getEmailPasswordStorage (process .getProcess ())
297
+ PasswordResetTokenInfo [] tokens = (( EmailPasswordSQLStorage ) StorageLayer .getStorage (process .getProcess () ))
296
298
.getAllPasswordResetTokenInfoForUser (new AppIdentifier (null , null ), user .id );
297
299
298
300
assert (tokens .length == 3 );
299
301
300
302
EmailPassword .resetPassword (process .getProcess (), tok , "newPassword" );
301
303
302
- tokens = StorageLayer .getEmailPasswordStorage (process .getProcess ())
304
+ tokens = (( EmailPasswordSQLStorage ) StorageLayer .getStorage (process .getProcess () ))
303
305
.getAllPasswordResetTokenInfoForUser (new AppIdentifier (null , null ), user .id );
304
306
assert (tokens .length == 0 );
305
307
@@ -328,7 +330,7 @@ public void zeroPasswordTokens() throws Exception {
328
330
if (StorageLayer .getStorage (process .getProcess ()).getType () != STORAGE_TYPE .SQL ) {
329
331
return ;
330
332
}
331
- PasswordResetTokenInfo [] tokens = StorageLayer .getEmailPasswordStorage (process .getProcess ())
333
+ PasswordResetTokenInfo [] tokens = (( EmailPasswordSQLStorage ) StorageLayer .getStorage (process .getProcess () ))
332
334
.getAllPasswordResetTokenInfoForUser (new AppIdentifier (null , null ),
333
335
"8ed86166-bfd8-4234-9dfe-abca9606dbd5" );
334
336
@@ -374,14 +376,14 @@ public void clashingPassowordResetToken() throws Exception {
374
376
// we add a user first.
375
377
UserInfo user =
EmailPassword .
signUp (
process .
getProcess (),
"[email protected] " ,
"password" );
376
378
377
- StorageLayer .getEmailPasswordStorage (process .getProcess ())
379
+ (( EmailPasswordSQLStorage ) StorageLayer .getStorage (process .getProcess () ))
378
380
.addPasswordResetToken (new AppIdentifier (null , null ), new PasswordResetTokenInfo (
379
381
user .id , "token" ,
380
382
System .currentTimeMillis () +
381
383
Config .getConfig (process .getProcess ()).getPasswordResetTokenLifetime ()));
382
384
383
385
try {
384
- StorageLayer .getEmailPasswordStorage (process .getProcess ())
386
+ (( EmailPasswordSQLStorage ) StorageLayer .getStorage (process .getProcess () ))
385
387
.addPasswordResetToken (new AppIdentifier (null , null ),
386
388
new PasswordResetTokenInfo (user .id , "token" , System .currentTimeMillis ()
387
389
+ Config .getConfig (process .getProcess ()).getPasswordResetTokenLifetime ()));
@@ -427,13 +429,13 @@ public void clashingUserIdDuringSignUp() throws Exception {
427
429
return ;
428
430
}
429
431
430
- StorageLayer .getEmailPasswordStorage (process .getProcess ())
432
+ (( EmailPasswordSQLStorage ) StorageLayer .getStorage (process .getProcess () ))
431
433
.signUp (new TenantIdentifier (null , null , null ), new UserInfo (
432
434
"8ed86166-bfd8-4234-9dfe-abca9606dbd5" ,
"[email protected] " ,
"password" ,
433
435
System .currentTimeMillis ()));
434
436
435
437
try {
436
- StorageLayer .getEmailPasswordStorage (process .getProcess ())
438
+ (( EmailPasswordSQLStorage ) StorageLayer .getStorage (process .getProcess () ))
437
439
.signUp (new TenantIdentifier (null , null , null ),
438
440
new UserInfo (
"8ed86166-bfd8-4234-9dfe-abca9606dbd5" ,
"[email protected] " ,
"password" ,
439
441
System .currentTimeMillis ()));
@@ -480,13 +482,13 @@ public void clashingEmailAndUserIdDuringSignUp() throws Exception {
480
482
return ;
481
483
}
482
484
483
- StorageLayer .getEmailPasswordStorage (process .getProcess ())
485
+ (( EmailPasswordSQLStorage ) StorageLayer .getStorage (process .getProcess () ))
484
486
.signUp (new TenantIdentifier (null , null , null ), new UserInfo (
485
487
"8ed86166-bfd8-4234-9dfe-abca9606dbd5" ,
"[email protected] " ,
"password" ,
486
488
System .currentTimeMillis ()));
487
489
488
490
try {
489
- StorageLayer .getEmailPasswordStorage (process .getProcess ())
491
+ (( EmailPasswordSQLStorage ) StorageLayer .getStorage (process .getProcess () ))
490
492
.signUp (new TenantIdentifier (null , null , null ),
491
493
new UserInfo (
"8ed86166-bfd8-4234-9dfe-abca9606dbd5" ,
"[email protected] " ,
"password" ,
492
494
System .currentTimeMillis ()));
0 commit comments