@@ -12,6 +12,7 @@ const MongoStorageAdapter = require('../lib/Adapters/Storage/Mongo/MongoStorageA
1212const request = require ( '../lib/request' ) ;
1313const passwordCrypto = require ( '../lib/password' ) ;
1414const Config = require ( '../lib/Config' ) ;
15+ const cryptoUtils = require ( '../lib/cryptoUtils' ) ;
1516
1617function verifyACL ( user ) {
1718 const ACL = user . getACL ( ) ;
@@ -2279,7 +2280,7 @@ describe('Parse.User testing', () => {
22792280 ) ;
22802281 } ) ;
22812282
2282- it ( 'signup should fail with duplicate case insensitive email' , async ( ) => {
2283+ it ( 'signup should fail with duplicate case insensitive email' , async ( ) => {
22832284 const user = new Parse . User ( ) ;
22842285 user . setUsername ( 'test1' ) ;
22852286 user . setPassword ( 'test' ) ;
@@ -2298,7 +2299,7 @@ describe('Parse.User testing', () => {
22982299 ) ;
22992300 } ) ;
23002301
2301- it ( 'edit should fail with duplicate case insensitive email' , async ( ) => {
2302+ it ( 'edit should fail with duplicate case insensitive email' , async ( ) => {
23022303 const user = new Parse . User ( ) ;
23032304 user . setUsername ( 'test1' ) ;
23042305 user . setPassword ( 'test' ) ;
@@ -2311,14 +2312,56 @@ describe('Parse.User testing', () => {
23112312 user2 . setEmail ( '[email protected] ' ) ; 23122313 await user2 . signUp ( ) ;
23132314
2314- user2 . setEmail ( '[email protected] ' ) 2315+ user2 . setEmail ( '[email protected] ' ) ; 23152316 await expectAsync ( user2 . save ( ) ) . toBeRejectedWith (
23162317 new Parse . Error (
23172318 Parse . Error . EMAIL_TAKEN ,
23182319 'Account already exists for this email address.'
23192320 )
23202321 ) ;
23212322 } ) ;
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+ } ) ;
23222365 } ) ;
23232366
23242367 it ( 'user cannot update email to existing user' , done => {
0 commit comments