Ignore _RevoableSession "header" that is sent by JS SDK. Fixes #1548. (#1627)

This commit is contained in:
Drew
2016-04-25 12:52:21 -07:00
committed by Florent Vilmart
parent 234d0093ff
commit 957b5927b1
4 changed files with 44 additions and 16 deletions

View File

@@ -1345,4 +1345,30 @@ describe('miscellaneous', function() {
}) })
}) })
it('ignores _RevocableSession "header" send by JS SDK', (done) => {
let object = new Parse.Object('AnObject');
object.set('a', 'b');
object.save().then(() => {
request.post({
headers: {'Content-Type': 'application/json'},
url: 'http://localhost:8378/1/classes/AnObject',
body: {
_method: 'GET',
_ApplicationId: 'test',
_JavaScriptKey: 'test',
_ClientVersion: 'js1.8.3',
_InstallationId: 'iid',
_RevocableSession: "1",
},
json: true
}, (err, res, body) => {
expect(body.error).toBeUndefined();
expect(body.results).not.toBeUndefined();
expect(body.results.length).toBe(1);
let result = body.results[0];
expect(result.a).toBe('b');
done();
})
});
});
}); });

View File

@@ -167,7 +167,6 @@ describe('rest query', () => {
expect(error).toBe(null); expect(error).toBe(null);
var b = JSON.parse(body); var b = JSON.parse(body);
expect(b.code).toEqual(Parse.Error.INVALID_QUERY); expect(b.code).toEqual(Parse.Error.INVALID_QUERY);
expect(b.error).toEqual('Improper encode of parameter');
done(); done();
}); });
}).then(() => { }).then(() => {
@@ -185,7 +184,6 @@ describe('rest query', () => {
expect(error).toBe(null); expect(error).toBe(null);
var b = JSON.parse(body); var b = JSON.parse(body);
expect(b.code).toEqual(Parse.Error.INVALID_QUERY); expect(b.code).toEqual(Parse.Error.INVALID_QUERY);
expect(b.error).toEqual('Improper encode of parameter');
done(); done();
}); });
}); });

View File

@@ -1,8 +1,8 @@
import PromiseRouter from '../PromiseRouter'; import PromiseRouter from '../PromiseRouter';
import rest from '../rest'; import rest from '../rest';
import url from 'url'; import url from 'url';
const ALLOWED_GET_QUERY_KEYS = ['keys', 'include']; const ALLOWED_GET_QUERY_KEYS = ['keys', 'include'];
@@ -16,7 +16,7 @@ export class ClassesRouter extends PromiseRouter {
for (let key of Object.keys(body)) { for (let key of Object.keys(body)) {
if (allowConstraints.indexOf(key) === -1) { if (allowConstraints.indexOf(key) === -1) {
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Improper encode of parameter'); throw new Parse.Error(Parse.Error.INVALID_QUERY, `Invalid paramater for query: ${key}`);
} }
} }

View File

@@ -45,6 +45,10 @@ function handleParseHeaders(req, res, next) {
fileViaJSON = true; fileViaJSON = true;
} }
if (req.body) {
delete req.body._RevocableSession;
}
if (req.body && if (req.body &&
req.body._ApplicationId && req.body._ApplicationId &&
cache.apps.get(req.body._ApplicationId) && cache.apps.get(req.body._ApplicationId) &&