-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Prevent Parse Server start in case of unknown option in server …
…configuration (#8987)
- Loading branch information
1 parent
f1469c6
commit 8758e6a
Showing
6 changed files
with
150 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const Config = require('../lib/Config'); | ||
const ParseServer = require('../lib/index').ParseServer; | ||
|
||
describe('Config Keys', () => { | ||
const tests = [ | ||
{ | ||
name: 'Invalid Root Keys', | ||
options: { unknow: 'val', masterKeyIPs: '' }, | ||
error: 'unknow, masterKeyIPs', | ||
}, | ||
{ name: 'Invalid Schema Keys', options: { schema: { Strict: 'val' } }, error: 'schema.Strict' }, | ||
{ | ||
name: 'Invalid Pages Keys', | ||
options: { pages: { customUrls: { EmailVerificationSendFail: 'val' } } }, | ||
error: 'pages.customUrls.EmailVerificationSendFail', | ||
}, | ||
{ | ||
name: 'Invalid LiveQueryServerOptions Keys', | ||
options: { liveQueryServerOptions: { MasterKey: 'value' } }, | ||
error: 'liveQueryServerOptions.MasterKey', | ||
}, | ||
{ | ||
name: 'Invalid RateLimit Keys - Array Item', | ||
options: { rateLimit: [{ RequestPath: '' }, { RequestTimeWindow: '' }] }, | ||
error: 'rateLimit[0].RequestPath, rateLimit[1].RequestTimeWindow', | ||
}, | ||
]; | ||
|
||
tests.forEach(test => { | ||
it(test.name, async () => { | ||
const logger = require('../lib/logger').logger; | ||
spyOn(logger, 'error').and.callThrough(); | ||
spyOn(Config, 'validateOptions').and.callFake(() => {}); | ||
|
||
new ParseServer({ | ||
...defaultConfiguration, | ||
...test.options, | ||
}); | ||
expect(logger.error).toHaveBeenCalledWith(`Invalid Option Keys Found: ${test.error}`); | ||
}); | ||
}); | ||
|
||
it('should run fine', async () => { | ||
try { | ||
await reconfigureServer({ | ||
...defaultConfiguration, | ||
}); | ||
} catch (err) { | ||
fail('Should run without error'); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters