Skip to content

Commit

Permalink
Merge pull request from GHSA-2479-qvv7-47qq
Browse files Browse the repository at this point in the history
* Failing test

* provide fix

* clearer test

* failing expect
  • Loading branch information
dplewis committed Jun 12, 2019
1 parent 54ba9a0 commit 8709daf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
25 changes: 25 additions & 0 deletions spec/AudienceRouter.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const auth = require('../lib/Auth');
const Config = require('../lib/Config');
const rest = require('../lib/rest');
const request = require('../lib/request');
const AudiencesRouter = require('../lib/Routers/AudiencesRouter')
.AudiencesRouter;

Expand Down Expand Up @@ -438,4 +439,28 @@ describe('AudiencesRouter', () => {
});
});
});

it('should handle _Audience invalid fields via rest', async () => {
await reconfigureServer({
appId: 'test',
restAPIKey: 'test',
publicServerURL: 'http://localhost:8378/1',
});
try {
await request({
method: 'POST',
url: 'http://localhost:8378/1/classes/_Audience',
body: { lorem: 'ipsum', _method: 'POST' },
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'test',
'Content-Type': 'application/json',
},
});
expect(true).toBeFalsy();
} catch (e) {
expect(e.data.code).toBe(107);
expect(e.data.error).toBe('Could not add field lorem');
}
});
});
7 changes: 4 additions & 3 deletions src/Controllers/SchemaController.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,7 @@ function validateCLP(perms: ClassLevelPermissions, fields: SchemaFields) {
// @flow-disable-next
throw new Parse.Error(
Parse.Error.INVALID_JSON,
`'${
perms[operation]
}' is not a valid value for class level permissions ${operation}`
`'${perms[operation]}' is not a valid value for class level permissions ${operation}`
);
} else {
perms[operation].forEach(key => {
Expand Down Expand Up @@ -395,6 +393,9 @@ class SchemaData {
this.__data = {};
this.__protectedFields = protectedFields;
allSchemas.forEach(schema => {
if (volatileClasses.includes(schema.className)) {
return;
}
Object.defineProperty(this, schema.className, {
get: () => {
if (!this.__data[schema.className]) {
Expand Down

0 comments on commit 8709daf

Please sign in to comment.