Results invalid session when providing an invalid session token (#2154)

* Results invalid session when providing an invalid session token

* Reverts unsafe loggers

* Fixes failing tests

- The tests were failin when run in sequence as we called done() before the JSSDK had a chance to register the session token, therefore having a proper logout call in afterEach
This commit is contained in:
Florent Vilmart
2016-06-26 23:20:02 -04:00
committed by GitHub
parent a861c4e506
commit 147b493e23
5 changed files with 69 additions and 23 deletions

View File

@@ -1589,7 +1589,7 @@ describe('Parse.User testing', () => {
bob.setPassword('meower');
return bob.save();
}).then(() => {
return Parse.User.logIn('bob', 'meower');
return Parse.User.logIn('bob', 'meower');
}).then((bob) => {
expect(bob.getUsername()).toEqual('bob');
done();
@@ -2091,7 +2091,7 @@ describe('Parse.User testing', () => {
fail('Save should have failed.');
done();
}, (e) => {
expect(e.code).toEqual(Parse.Error.SESSION_MISSING);
expect(e.code).toEqual(Parse.Error.INVALID_SESSION_TOKEN);
done();
});
});
@@ -2124,6 +2124,26 @@ describe('Parse.User testing', () => {
});
});
it("invalid session tokens are rejected", (done) => {
Parse.User.signUp("asdf", "zxcv", null, {
success: function(user) {
request.get({
url: 'http://localhost:8378/1/classes/AClass',
json: true,
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-Rest-API-Key': 'rest',
'X-Parse-Session-Token': 'text'
},
}, (error, response, body) => {
expect(body.code).toBe(209);
expect(body.error).toBe('invalid session token');
done();
})
}
});
});
it_exclude_dbs(['postgres'])('should cleanup null authData keys (regression test for #935)', (done) => {
let database = new Config(Parse.applicationId).database;
database.create('_User', {
@@ -2374,7 +2394,7 @@ describe('Parse.User testing', () => {
})
.then(() => obj.fetch())
.catch(error => {
expect(error.code).toEqual(Parse.Error.OBJECT_NOT_FOUND);
expect(error.code).toEqual(Parse.Error.INVALID_SESSION_TOKEN);
done();
});
})