Move transform acl (#2021)
* Move ACL transforming into Parse Server For the database adapters, it will be more performant and easier to work with _rperm and _wperm than with the ACL object. This way we can type it as an array and so on, and once we have stronger validations in Parse Server, we can type it as an array containing strings of length < x, which will be much much better in sql databases. * Use destructuring
This commit is contained in:
@@ -58,10 +58,9 @@ describe('parseObjectToMongoObjectForCreate', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
it('basic ACL', (done) => {
|
||||
it('Doesnt allow ACL, as Parse Server should tranform ACL to _wperm + _rperm', done => {
|
||||
var input = {ACL: {'0123': {'read': true, 'write': true}}};
|
||||
var output = transform.parseObjectToMongoObjectForCreate(null, input, { fields: {} });
|
||||
// This just checks that it doesn't crash, but it should check format.
|
||||
expect(() => transform.parseObjectToMongoObjectForCreate(null, input, { fields: {} })).toThrow();
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -220,28 +219,10 @@ describe('transform schema key changes', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
it('changes ACL storage to _rperm and _wperm', (done) => {
|
||||
var input = {
|
||||
ACL: {
|
||||
"*": { "read": true },
|
||||
"Kevin": { "write": true }
|
||||
}
|
||||
};
|
||||
var output = transform.parseObjectToMongoObjectForCreate(null, input, { fields: {} });
|
||||
expect(typeof output._rperm).toEqual('object');
|
||||
expect(typeof output._wperm).toEqual('object');
|
||||
expect(output.ACL).toBeUndefined();
|
||||
expect(output._rperm[0]).toEqual('*');
|
||||
expect(output._wperm[0]).toEqual('Kevin');
|
||||
done();
|
||||
});
|
||||
|
||||
it('writes the old ACL format in addition to rperm and wperm', (done) => {
|
||||
var input = {
|
||||
ACL: {
|
||||
"*": { "read": true },
|
||||
"Kevin": { "write": true }
|
||||
}
|
||||
_rperm: ['*'],
|
||||
_wperm: ['Kevin'],
|
||||
};
|
||||
|
||||
var output = transform.parseObjectToMongoObjectForCreate(null, input, { fields: {} });
|
||||
@@ -257,11 +238,9 @@ describe('transform schema key changes', () => {
|
||||
_wperm: ["Kevin"]
|
||||
};
|
||||
var output = transform.mongoObjectToParseObject(null, input, { fields: {} });
|
||||
expect(typeof output.ACL).toEqual('object');
|
||||
expect(output._rperm).toBeUndefined();
|
||||
expect(output._wperm).toBeUndefined();
|
||||
expect(output.ACL['*']['read']).toEqual(true);
|
||||
expect(output.ACL['Kevin']['write']).toEqual(true);
|
||||
expect(output._rperm).toEqual(['*']);
|
||||
expect(output._wperm).toEqual(['Kevin']);
|
||||
expect(output.ACL).toBeUndefined()
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user