@@ -12,6 +12,7 @@ const MongoStorageAdapter = require('../lib/Adapters/Storage/Mongo/MongoStorageA
12
12
const request = require ( '../lib/request' ) ;
13
13
const passwordCrypto = require ( '../lib/password' ) ;
14
14
const Config = require ( '../lib/Config' ) ;
15
+ const cryptoUtils = require ( '../lib/cryptoUtils' ) ;
15
16
16
17
function verifyACL ( user ) {
17
18
const ACL = user . getACL ( ) ;
@@ -2279,7 +2280,7 @@ describe('Parse.User testing', () => {
2279
2280
) ;
2280
2281
} ) ;
2281
2282
2282
- it ( 'signup should fail with duplicate case insensitive email' , async ( ) => {
2283
+ it ( 'signup should fail with duplicate case insensitive email' , async ( ) => {
2283
2284
const user = new Parse . User ( ) ;
2284
2285
user . setUsername ( 'test1' ) ;
2285
2286
user . setPassword ( 'test' ) ;
@@ -2298,7 +2299,7 @@ describe('Parse.User testing', () => {
2298
2299
) ;
2299
2300
} ) ;
2300
2301
2301
- it ( 'edit should fail with duplicate case insensitive email' , async ( ) => {
2302
+ it ( 'edit should fail with duplicate case insensitive email' , async ( ) => {
2302
2303
const user = new Parse . User ( ) ;
2303
2304
user . setUsername ( 'test1' ) ;
2304
2305
user . setPassword ( 'test' ) ;
@@ -2311,14 +2312,56 @@ describe('Parse.User testing', () => {
2311
2312
user2 . setEmail ( '[email protected] ' ) ;
2312
2313
await user2 . signUp ( ) ;
2313
2314
2314
- user2 . setEmail ( '[email protected] ' )
2315
+ user2 . setEmail ( '[email protected] ' ) ;
2315
2316
await expectAsync ( user2 . save ( ) ) . toBeRejectedWith (
2316
2317
new Parse . Error (
2317
2318
Parse . Error . EMAIL_TAKEN ,
2318
2319
'Account already exists for this email address.'
2319
2320
)
2320
2321
) ;
2321
2322
} ) ;
2323
+
2324
+ describe ( 'anonymous users' , ( ) => {
2325
+ beforeEach ( ( ) => {
2326
+ const insensitiveCollisions = [
2327
+ 'abcdefghijklmnop' ,
2328
+ 'Abcdefghijklmnop' ,
2329
+ 'ABcdefghijklmnop' ,
2330
+ 'ABCdefghijklmnop' ,
2331
+ 'ABCDefghijklmnop' ,
2332
+ 'ABCDEfghijklmnop' ,
2333
+ 'ABCDEFghijklmnop' ,
2334
+ 'ABCDEFGhijklmnop' ,
2335
+ 'ABCDEFGHijklmnop' ,
2336
+ 'ABCDEFGHIjklmnop' ,
2337
+ 'ABCDEFGHIJklmnop' ,
2338
+ 'ABCDEFGHIJKlmnop' ,
2339
+ 'ABCDEFGHIJKLmnop' ,
2340
+ 'ABCDEFGHIJKLMnop' ,
2341
+ 'ABCDEFGHIJKLMnop' ,
2342
+ 'ABCDEFGHIJKLMNop' ,
2343
+ 'ABCDEFGHIJKLMNOp' ,
2344
+ 'ABCDEFGHIJKLMNOP' ,
2345
+ ] ;
2346
+ // Random String gets called a lot before we get to relevant code
2347
+ spyOn ( cryptoUtils , 'randomString' ) . and . returnValues (
2348
+ ...insensitiveCollisions
2349
+ ) ;
2350
+ } ) ;
2351
+
2352
+ it ( 'should not fail on case insensitive matches' , async ( ) => {
2353
+ const user1 = await Parse . AnonymousUtils . logIn ( ) ;
2354
+ const username1 = user1 . get ( 'username' ) ;
2355
+ expect ( username1 ) . not . toBeUndefined ( ) ;
2356
+
2357
+ const user2 = await Parse . AnonymousUtils . logIn ( ) ;
2358
+ const username2 = user2 . get ( 'username' ) ;
2359
+ expect ( username2 ) . not . toBeUndefined ( ) ;
2360
+
2361
+ expect ( username2 ) . not . toBe ( username1 ) ;
2362
+ expect ( username2 . toLowerCase ( ) ) . toBe ( username1 . toLowerCase ( ) ) ;
2363
+ } ) ;
2364
+ } ) ;
2322
2365
} ) ;
2323
2366
2324
2367
it ( 'user cannot update email to existing user' , done => {
0 commit comments