Makes sure _acl is set as empty {} (#2495)
* regression test for #2465 * Makes sure _acl is set when locked down - Fixes #2465
This commit is contained in:
@@ -1478,4 +1478,37 @@ describe('miscellaneous', function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it_exclude_dbs(['postgres'])('should have _acl when locking down (regression for #2465)', (done) => {
|
||||||
|
let headers = {
|
||||||
|
'X-Parse-Application-Id': 'test',
|
||||||
|
'X-Parse-REST-API-Key': 'rest'
|
||||||
|
}
|
||||||
|
rp({
|
||||||
|
method: 'POST',
|
||||||
|
headers: headers,
|
||||||
|
uri: 'http://localhost:8378/1/classes/Report',
|
||||||
|
body: {
|
||||||
|
ACL: {},
|
||||||
|
name: 'My Report'
|
||||||
|
},
|
||||||
|
json: true
|
||||||
|
}).then(() => {
|
||||||
|
let config = new Config('test');
|
||||||
|
let adapter = config.database.adapter;
|
||||||
|
return adapter._adaptiveCollection("Report")
|
||||||
|
.then(collection => collection.find({}))
|
||||||
|
}).then((results) => {
|
||||||
|
expect(results.length).toBe(1);
|
||||||
|
let result = results[0];
|
||||||
|
expect(result.name).toEqual('My Report');
|
||||||
|
expect(result._wperm).toEqual([]);
|
||||||
|
expect(result._rperm).toEqual([]);
|
||||||
|
expect(result._acl).toEqual({});
|
||||||
|
done();
|
||||||
|
}).catch((err) => {
|
||||||
|
fail(JSON.stringify(err));
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -341,6 +341,7 @@ const addLegacyACL = restObject => {
|
|||||||
restObject._wperm.forEach(entry => {
|
restObject._wperm.forEach(entry => {
|
||||||
_acl[entry] = { w: true };
|
_acl[entry] = { w: true };
|
||||||
});
|
});
|
||||||
|
restObjectCopy._acl = _acl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (restObject._rperm) {
|
if (restObject._rperm) {
|
||||||
@@ -351,9 +352,6 @@ const addLegacyACL = restObject => {
|
|||||||
_acl[entry].r = true;
|
_acl[entry].r = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if (Object.keys(_acl).length > 0) {
|
|
||||||
restObjectCopy._acl = _acl;
|
restObjectCopy._acl = _acl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user