@@ -213,6 +213,71 @@ describe('Parse.User testing', () => {
213213 } )
214214 } ) ;
215215
216+ it ( 'should let masterKey lockout user' , ( done ) => {
217+ const user = new Parse . User ( ) ;
218+ const ACL = new Parse . ACL ( ) ;
219+ ACL . setPublicReadAccess ( false ) ;
220+ ACL . setPublicWriteAccess ( false ) ;
221+ user . setUsername ( 'asdf' ) ;
222+ user . setPassword ( 'zxcv' ) ;
223+ user . setACL ( ACL ) ;
224+ user . signUp ( ) . then ( ( ) => {
225+ return Parse . User . logIn ( "asdf" , "zxcv" ) ;
226+ } ) . then ( ( user ) => {
227+ equal ( user . get ( "username" ) , "asdf" ) ;
228+ // Lock the user down
229+ const ACL = new Parse . ACL ( ) ;
230+ user . setACL ( ACL ) ;
231+ return user . save ( null , { useMasterKey : true } ) ;
232+ } ) . then ( ( ) => {
233+ expect ( user . getACL ( ) . getPublicReadAccess ( ) ) . toBe ( false ) ;
234+ return Parse . User . logIn ( "asdf" , "zxcv" ) ;
235+ } ) . then ( done . fail ) . catch ( ( err ) => {
236+ expect ( err . message ) . toBe ( 'Invalid username/password.' ) ;
237+ expect ( err . code ) . toBe ( Parse . Error . OBJECT_NOT_FOUND ) ;
238+ done ( ) ;
239+ } ) ;
240+ } ) ;
241+
242+ it ( 'should be let masterKey lock user out with authData' , ( done ) => {
243+ let objectId ;
244+ let sessionToken ;
245+
246+ rp . post ( {
247+ url : 'http://localhost:8378/1/classes/_User' ,
248+ headers : {
249+ 'X-Parse-Application-Id' : Parse . applicationId ,
250+ 'X-Parse-REST-API-Key' : 'rest' ,
251+ } ,
252+ json : { key : "value" , authData : { anonymous : { id : '00000000-0000-0000-0000-000000000001' } } }
253+ } ) . then ( ( body ) => {
254+ objectId = body . objectId ;
255+ sessionToken = body . sessionToken ;
256+ expect ( sessionToken ) . toBeDefined ( ) ;
257+ expect ( objectId ) . toBeDefined ( ) ;
258+ const user = new Parse . User ( ) ;
259+ user . id = objectId ;
260+ const ACL = new Parse . ACL ( ) ;
261+ user . setACL ( ACL ) ;
262+ return user . save ( null , { useMasterKey : true } ) ;
263+ } ) . then ( ( ) => {
264+ // update the user
265+ const options = {
266+ url : `http://localhost:8378/1/classes/_User/` ,
267+ headers : {
268+ 'X-Parse-Application-Id' : Parse . applicationId ,
269+ 'X-Parse-REST-API-Key' : 'rest' ,
270+ } ,
271+ json : { key : "otherValue" , authData : { anonymous : { id : '00000000-0000-0000-0000-000000000001' } } }
272+ }
273+ return rp . post ( options ) ;
274+ } ) . then ( ( res ) => {
275+ // Because the user is locked out, this should behave as creating a new user
276+ expect ( res . objectId ) . not . toEqual ( objectId ) ;
277+ } ) . then ( done )
278+ . catch ( done . fail ) ;
279+ } ) ;
280+
216281 it ( "user login with files" , ( done ) => {
217282 const file = new Parse . File ( "yolo.txt" , [ 1 , 2 , 3 ] , "text/plain" ) ;
218283 file . save ( ) . then ( ( file ) => {
0 commit comments