Skip to content
2 changes: 2 additions & 0 deletions spec/MongoSchemaCollectionAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('MongoSchemaCollection', () => {
create: { '*': true },
delete: { '*': true },
addField: { '*': true },
protectedFields: { '*': [] },
},
indexes: {
name1: { deviceToken: 1 },
Expand Down Expand Up @@ -72,6 +73,7 @@ describe('MongoSchemaCollection', () => {
update: { '*': true },
delete: { '*': true },
addField: { '*': true },
protectedFields: { '*': [] },
},
indexes: {
name1: { deviceToken: 1 },
Expand Down
4 changes: 4 additions & 0 deletions spec/ParseLiveQueryServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ describe('ParseLiveQueryServer', function() {
find: {},
update: {},
delete: { '*': true },
protectedFields: {},
});

expect(deleteSpy).toHaveBeenCalled();
Expand All @@ -270,6 +271,7 @@ describe('ParseLiveQueryServer', function() {
find: {},
update: {},
delete: { '*': true },
protectedFields: {},
});
done();
})
Expand Down Expand Up @@ -1920,6 +1922,7 @@ describe('LiveQueryController', () => {
find: {},
update: {},
delete: { '*': true },
protectedFields: {},
});

expect(deleteSpy).toHaveBeenCalled();
Expand All @@ -1933,6 +1936,7 @@ describe('LiveQueryController', () => {
find: {},
update: {},
delete: { '*': true },
protectedFields: {},
});
done();
})
Expand Down
70 changes: 70 additions & 0 deletions spec/Schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ describe('SchemaController', () => {
update: { '*': true },
delete: { '*': true },
addField: { '*': true },
protectedFields: { '*': [] },
},
};
expect(dd(actualSchema, expectedSchema)).toEqual(undefined);
Expand All @@ -338,6 +339,7 @@ describe('SchemaController', () => {
update: { '*': true },
delete: { '*': true },
addField: { '*': true },
protectedFields: { '*': [] },
};
config.database.loadSchema().then(schema => {
schema
Expand Down Expand Up @@ -461,6 +463,7 @@ describe('SchemaController', () => {
update: { '*': true },
delete: { '*': true },
addField: { '*': true },
protectedFields: { '*': [] },
},
};
expect(dd(actualSchema, expectedSchema)).toEqual(undefined);
Expand Down Expand Up @@ -653,6 +656,68 @@ describe('SchemaController', () => {
});
});

it('refuses to add CLP with incorrect find', done => {
const levelPermissions = {
find: { '*': false },
get: { '*': true },
create: { '*': true },
update: { '*': true },
delete: { '*': true },
addField: { '*': true },
protectedFields: { '*': ['email'] },
};
config.database.loadSchema().then(schema => {
schema
.validateObject('NewClass', {})
.then(() => schema.reloadData())
.then(() =>
schema.updateClass(
'NewClass',
{},
levelPermissions,
{},
config.database
)
)
.then(done.fail)
.catch(error => {
expect(error.code).toEqual(Parse.Error.INVALID_JSON);
done();
});
});
});

it('refuses to add CLP when incorrectly sending a string to protectedFields object value instead of an array', done => {
const levelPermissions = {
find: { '*': true },
get: { '*': true },
create: { '*': true },
update: { '*': true },
delete: { '*': true },
addField: { '*': true },
protectedFields: { '*': 'email' },
};
config.database.loadSchema().then(schema => {
schema
.validateObject('NewClass', {})
.then(() => schema.reloadData())
.then(() =>
schema.updateClass(
'NewClass',
{},
levelPermissions,
{},
config.database
)
)
.then(done.fail)
.catch(error => {
expect(error.code).toEqual(Parse.Error.INVALID_JSON);
done();
});
});
});

it('will create classes', done => {
config.database
.loadSchema()
Expand Down Expand Up @@ -706,6 +771,7 @@ describe('SchemaController', () => {
update: { '*': true },
delete: { '*': true },
addField: { '*': true },
protectedFields: { '*': [] },
},
};
expect(dd(actualSchema, expectedSchema)).toEqual(undefined);
Expand Down Expand Up @@ -751,6 +817,7 @@ describe('SchemaController', () => {
update: { '*': true },
delete: { '*': true },
addField: { '*': true },
protectedFields: { '*': [] },
},
};
expect(dd(actualSchema, expectedSchema)).toEqual(undefined);
Expand Down Expand Up @@ -782,6 +849,7 @@ describe('SchemaController', () => {
update: { '*': true },
delete: { '*': true },
addField: { '*': true },
protectedFields: { '*': [] },
},
};
expect(dd(actualSchema, expectedSchema)).toEqual(undefined);
Expand Down Expand Up @@ -815,6 +883,7 @@ describe('SchemaController', () => {
update: { '*': true },
delete: { '*': true },
addField: { '*': true },
protectedFields: { '*': [] },
},
};
expect(dd(actualSchema, expectedSchema)).toEqual(undefined);
Expand Down Expand Up @@ -1002,6 +1071,7 @@ describe('SchemaController', () => {
update: { '*': true },
delete: { '*': true },
addField: { '*': true },
protectedFields: { '*': [] },
},
};
expect(dd(actualSchema, expectedSchema)).toEqual(undefined);
Expand Down
Loading