Refactors configuration management (#4271)
* Adds flow types / Configuration interfaces * Lets call it options * Use a single interface to generate the configurations * Translates options to definitions only if comments are set * improves logic * Moves objects around * Fixes issue affecting logging of circular objects * fixes undefined env * Moves all defaults to defaults * Adds back CLI defaults * Restored defaults in commander.js * Merge provided defaults and platform defaults * Addresses visual nits * Improves Config.js code * Adds ability to pass the default value in trailing comments * Load platform defaults from the definitions file * proper default values on various options * Adds ParseServer.start and server.start(options) as quick startup methods * Moves creating liveQueryServer http into ParseServer.js * removes dead code * Adds tests to guarantee we can start a LQ Server from main module * Fixes incorrect code regading liveQuery init port * Start a http server for LQ if port is specified * ensure we dont fail if config.port is not set * Specify port * ignore other path skipped in tests * Adds test for custom middleware setting * Refactors new Config into Config.get - Hides AppCache from ParseServer.js, use Config.put which validates * Extracts controller creation into Controllers/index.js - This makes the ParseServer init way simpler * Move serverURL inference into ParseServer * review nits
This commit is contained in:
@@ -4,11 +4,11 @@ var Config = require('../src/Config');
|
||||
describe('Pointer Permissions', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
new Config(Parse.applicationId).database.schemaCache.clear();
|
||||
Config.get(Parse.applicationId).database.schemaCache.clear();
|
||||
});
|
||||
|
||||
it('should work with find', (done) => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const user = new Parse.User();
|
||||
const user2 = new Parse.User();
|
||||
user.set({
|
||||
@@ -47,7 +47,7 @@ describe('Pointer Permissions', () => {
|
||||
|
||||
|
||||
it('should work with write', (done) => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const user = new Parse.User();
|
||||
const user2 = new Parse.User();
|
||||
user.set({
|
||||
@@ -112,7 +112,7 @@ describe('Pointer Permissions', () => {
|
||||
});
|
||||
|
||||
it('should let a proper user find', (done) => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const user = new Parse.User();
|
||||
const user2 = new Parse.User();
|
||||
user.set({
|
||||
@@ -172,7 +172,7 @@ describe('Pointer Permissions', () => {
|
||||
});
|
||||
|
||||
it('should query on pointer permission enabled column', (done) => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const user = new Parse.User();
|
||||
const user2 = new Parse.User();
|
||||
user.set({
|
||||
@@ -213,7 +213,7 @@ describe('Pointer Permissions', () => {
|
||||
});
|
||||
|
||||
it('should not allow creating objects', (done) => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const user = new Parse.User();
|
||||
user.set({
|
||||
username: 'user1',
|
||||
@@ -239,7 +239,7 @@ describe('Pointer Permissions', () => {
|
||||
});
|
||||
|
||||
it('should handle multiple writeUserFields', done => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const user = new Parse.User();
|
||||
const user2 = new Parse.User();
|
||||
user.set({
|
||||
@@ -278,7 +278,7 @@ describe('Pointer Permissions', () => {
|
||||
});
|
||||
|
||||
it('should prevent creating pointer permission on missing field', (done) => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
config.database.loadSchema().then((schema) => {
|
||||
return schema.addClassIfNotExists('AnObject', {}, {create: {}, writeUserFields: ['owner'], readUserFields: ['owner']});
|
||||
}).then(() => {
|
||||
@@ -291,7 +291,7 @@ describe('Pointer Permissions', () => {
|
||||
});
|
||||
|
||||
it('should prevent creating pointer permission on bad field', (done) => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
config.database.loadSchema().then((schema) => {
|
||||
return schema.addClassIfNotExists('AnObject', {owner: {type: 'String'}}, {create: {}, writeUserFields: ['owner'], readUserFields: ['owner']});
|
||||
}).then(() => {
|
||||
@@ -304,7 +304,7 @@ describe('Pointer Permissions', () => {
|
||||
});
|
||||
|
||||
it('should prevent creating pointer permission on bad field', (done) => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const object = new Parse.Object('AnObject');
|
||||
object.set('owner', 'value');
|
||||
object.save().then(() => {
|
||||
@@ -329,7 +329,7 @@ describe('Pointer Permissions', () => {
|
||||
|
||||
The owner is another user than the ACL
|
||||
*/
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const user = new Parse.User();
|
||||
const user2 = new Parse.User();
|
||||
user.set({
|
||||
@@ -374,7 +374,7 @@ describe('Pointer Permissions', () => {
|
||||
PointerPerm: "owner"
|
||||
ACL: logged in user has access
|
||||
*/
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const user = new Parse.User();
|
||||
const user2 = new Parse.User();
|
||||
user.set({
|
||||
@@ -419,7 +419,7 @@ describe('Pointer Permissions', () => {
|
||||
PointerPerm: "owner"
|
||||
ACL: logged in user has access
|
||||
*/
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const user = new Parse.User();
|
||||
const user2 = new Parse.User();
|
||||
user.set({
|
||||
@@ -466,7 +466,7 @@ describe('Pointer Permissions', () => {
|
||||
|
||||
The owner is another user than the ACL
|
||||
*/
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const user = new Parse.User();
|
||||
const user2 = new Parse.User();
|
||||
user.set({
|
||||
@@ -511,7 +511,7 @@ describe('Pointer Permissions', () => {
|
||||
PointerPerm: "owner" : read
|
||||
ACL: logged in user has access
|
||||
*/
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const user = new Parse.User();
|
||||
const user2 = new Parse.User();
|
||||
user.set({
|
||||
@@ -558,7 +558,7 @@ describe('Pointer Permissions', () => {
|
||||
PointerPerm: "owner" : read // proper owner
|
||||
ACL: logged in user has not access
|
||||
*/
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const user = new Parse.User();
|
||||
const user2 = new Parse.User();
|
||||
user.set({
|
||||
@@ -597,7 +597,7 @@ describe('Pointer Permissions', () => {
|
||||
});
|
||||
|
||||
it('should let master key find objects', (done) => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const object = new Parse.Object('AnObject');
|
||||
object.set('hello', 'world');
|
||||
return object.save().then(() => {
|
||||
@@ -626,7 +626,7 @@ describe('Pointer Permissions', () => {
|
||||
});
|
||||
|
||||
it('should let master key get objects', (done) => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const object = new Parse.Object('AnObject');
|
||||
object.set('hello', 'world');
|
||||
return object.save().then(() => {
|
||||
@@ -657,7 +657,7 @@ describe('Pointer Permissions', () => {
|
||||
|
||||
|
||||
it('should let master key update objects', (done) => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const object = new Parse.Object('AnObject');
|
||||
object.set('hello', 'world');
|
||||
return object.save().then(() => {
|
||||
@@ -684,7 +684,7 @@ describe('Pointer Permissions', () => {
|
||||
});
|
||||
|
||||
it('should let master key delete objects', (done) => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const object = new Parse.Object('AnObject');
|
||||
object.set('hello', 'world');
|
||||
return object.save().then(() => {
|
||||
@@ -710,7 +710,7 @@ describe('Pointer Permissions', () => {
|
||||
});
|
||||
|
||||
it('should fail with invalid pointer perms', (done) => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
config.database.loadSchema().then((schema) => {
|
||||
// Lock the update, and let only owner write
|
||||
return schema.addClassIfNotExists('AnObject', {owner: {type: 'Pointer', targetClass: '_User'}}, {delete: {}, writeUserFields: 'owner'});
|
||||
@@ -721,7 +721,7 @@ describe('Pointer Permissions', () => {
|
||||
});
|
||||
|
||||
it('should fail with invalid pointer perms', (done) => {
|
||||
const config = new Config(Parse.applicationId);
|
||||
const config = Config.get(Parse.applicationId);
|
||||
config.database.loadSchema().then((schema) => {
|
||||
// Lock the update, and let only owner write
|
||||
return schema.addClassIfNotExists('AnObject', {owner: {type: 'Pointer', targetClass: '_User'}}, {delete: {}, writeUserFields: ['owner', 'invalid']});
|
||||
|
||||
Reference in New Issue
Block a user