@@ -390,7 +390,7 @@ describe('Parse.User testing', () => {
390390 expect ( newUser ) . not . toBeUndefined ( ) ;
391391 } ) ;
392392
393- it ( ' should be let masterKey lock user out with authData ', async ( ) => {
393+ it_only_db ( 'mongo' ) ( ' should reject duplicate authData when masterKey locks user out', async ( ) => {
394394 const response = await request ( {
395395 method : 'POST' ,
396396 url : 'http://localhost:8378/1/classes/_User' ,
@@ -406,15 +406,61 @@ describe('Parse.User testing', () => {
406406 } ) ;
407407 const body = response . data ;
408408 const objectId = body . objectId ;
409- const sessionToken = body . sessionToken ;
410- expect ( sessionToken ) . toBeDefined ( ) ;
409+ expect ( body . sessionToken ) . toBeDefined ( ) ;
410+ expect ( objectId ) . toBeDefined ( ) ;
411+ const user = new Parse . User ( ) ;
412+ user . id = objectId ;
413+ const ACL = new Parse . ACL ( ) ;
414+ user . setACL ( ACL ) ;
415+ await user . save ( null , { useMasterKey : true } ) ;
416+ const options = {
417+ method : 'POST' ,
418+ url : `http://localhost:8378/1/classes/_User/` ,
419+ headers : {
420+ 'X-Parse-Application-Id' : Parse . applicationId ,
421+ 'X-Parse-REST-API-Key' : 'rest' ,
422+ 'Content-Type' : 'application/json' ,
423+ } ,
424+ body : {
425+ key : 'otherValue' ,
426+ authData : {
427+ anonymous : { id : '00000000-0000-0000-0000-000000000001' } ,
428+ } ,
429+ } ,
430+ } ;
431+ try {
432+ await request ( options ) ;
433+ fail ( 'should have thrown' ) ;
434+ } catch ( err ) {
435+ expect ( err . data . code ) . toBe ( 208 ) ;
436+ expect ( err . data . error ) . toBe ( 'this auth is already used' ) ;
437+ }
438+ } ) ;
439+
440+ it_only_db ( 'postgres' ) ( 'should reject duplicate authData when masterKey locks user out' , async ( ) => {
441+ await reconfigureServer ( ) ;
442+ const response = await request ( {
443+ method : 'POST' ,
444+ url : 'http://localhost:8378/1/classes/_User' ,
445+ headers : {
446+ 'X-Parse-Application-Id' : Parse . applicationId ,
447+ 'X-Parse-REST-API-Key' : 'rest' ,
448+ 'Content-Type' : 'application/json' ,
449+ } ,
450+ body : {
451+ key : 'value' ,
452+ authData : { anonymous : { id : '00000000-0000-0000-0000-000000000001' } } ,
453+ } ,
454+ } ) ;
455+ const body = response . data ;
456+ const objectId = body . objectId ;
457+ expect ( body . sessionToken ) . toBeDefined ( ) ;
411458 expect ( objectId ) . toBeDefined ( ) ;
412459 const user = new Parse . User ( ) ;
413460 user . id = objectId ;
414461 const ACL = new Parse . ACL ( ) ;
415462 user . setACL ( ACL ) ;
416463 await user . save ( null , { useMasterKey : true } ) ;
417- // update the user
418464 const options = {
419465 method : 'POST' ,
420466 url : `http://localhost:8378/1/classes/_User/` ,
0 commit comments