Skip to content

Commit 2f1ee21

Browse files
flovilmartdrew-gross
authored andcommitted
Makes sure _acl is set as empty {} (#2495)
* regression test for #2465 * Makes sure _acl is set when locked down - Fixes #2465
1 parent e690b73 commit 2f1ee21

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

spec/ParseAPI.spec.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,4 +1478,37 @@ describe('miscellaneous', function() {
14781478
done();
14791479
});
14801480
});
1481+
1482+
it_exclude_dbs(['postgres'])('should have _acl when locking down (regression for #2465)', (done) =>  {
1483+
let headers = {
1484+
'X-Parse-Application-Id': 'test',
1485+
'X-Parse-REST-API-Key': 'rest'
1486+
}
1487+
rp({
1488+
method: 'POST',
1489+
headers: headers,
1490+
uri: 'http://localhost:8378/1/classes/Report',
1491+
body: {
1492+
ACL: {},
1493+
name: 'My Report'
1494+
},
1495+
json: true
1496+
}).then(() => {
1497+
let config = new Config('test');
1498+
let adapter = config.database.adapter;
1499+
return adapter._adaptiveCollection("Report")
1500+
.then(collection => collection.find({}))
1501+
}).then((results) => {
1502+
expect(results.length).toBe(1);
1503+
let result = results[0];
1504+
expect(result.name).toEqual('My Report');
1505+
expect(result._wperm).toEqual([]);
1506+
expect(result._rperm).toEqual([]);
1507+
expect(result._acl).toEqual({});
1508+
done();
1509+
}).catch((err) => {
1510+
fail(JSON.stringify(err));
1511+
done();
1512+
});
1513+
});
14811514
});

src/Adapters/Storage/Mongo/MongoTransform.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ const addLegacyACL = restObject => {
341341
restObject._wperm.forEach(entry => {
342342
_acl[entry] = { w: true };
343343
});
344+
restObjectCopy._acl = _acl;
344345
}
345346

346347
if (restObject._rperm) {
@@ -351,9 +352,6 @@ const addLegacyACL = restObject => {
351352
_acl[entry].r = true;
352353
}
353354
});
354-
}
355-
356-
if (Object.keys(_acl).length > 0) {
357355
restObjectCopy._acl = _acl;
358356
}
359357

0 commit comments

Comments
 (0)