Fix/user update issue (#4123)
* Adds failing test, the _User object is not updated as soon as you pass some authData part of the PUT * Do not run the DB call when updating the user with new auth data, just part of the rest
This commit is contained in:
@@ -3116,4 +3116,58 @@ describe('Parse.User testing', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to update user with authData passed', (done) => {
|
||||
let objectId;
|
||||
let sessionToken;
|
||||
|
||||
function validate(block) {
|
||||
return rp.get({
|
||||
url: `http://localhost:8378/1/classes/_User/${objectId}`,
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-REST-API-Key': 'rest',
|
||||
'X-Parse-Session-Token': sessionToken
|
||||
},
|
||||
json: true,
|
||||
}).then(block);
|
||||
}
|
||||
|
||||
rp.post({
|
||||
url: 'http://localhost:8378/1/classes/_User',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-REST-API-Key': 'rest',
|
||||
},
|
||||
json: { key: "value", authData: {anonymous: {id: '00000000-0000-0000-0000-000000000001'}}}
|
||||
}).then((body) => {
|
||||
objectId = body.objectId;
|
||||
sessionToken = body.sessionToken;
|
||||
expect(sessionToken).toBeDefined();
|
||||
expect(objectId).toBeDefined();
|
||||
return validate((user) => { // validate that keys are set on creation
|
||||
expect(user.key).toBe("value");
|
||||
});
|
||||
}).then(() => {
|
||||
// update the user
|
||||
const options = {
|
||||
url: `http://localhost:8378/1/classes/_User/${objectId}`,
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-REST-API-Key': 'rest',
|
||||
'X-Parse-Session-Token': sessionToken
|
||||
},
|
||||
json: { key: "otherValue", authData: {anonymous: {id: '00000000-0000-0000-0000-000000000001'}}}
|
||||
}
|
||||
return rp.put(options);
|
||||
}).then(() => {
|
||||
return validate((user) => { // validate that keys are set on update
|
||||
expect(user.key).toBe("otherValue");
|
||||
});
|
||||
}).then(() => {
|
||||
done();
|
||||
})
|
||||
.then(done)
|
||||
.catch(done.fail);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user