Validate serverURL on Start (#4204)

* Added basic validation of publicServerURL

* Fixed up 'verifyServerUrl' and added tests

* Use Parse.serverURL instead, general cleanup.

* Test server port moved to 13376

* Removed reconfigureServer calls with simple changing of Parse.serverURL

* changed var to const

* Disabled automatic serverURL verification during testing, moved verification call into app.on('mount') callback, removed setTimeout from verification.
This commit is contained in:
Benjamin Wilson Friedman
2017-10-17 11:49:28 -07:00
committed by Florent Vilmart
parent 9745caf9fb
commit 9376b4d04a
2 changed files with 61 additions and 1 deletions

34
spec/ParseServer.spec.js Normal file
View File

@@ -0,0 +1,34 @@
'use strict';
/* Tests for ParseServer.js */
const express = require('express');
import ParseServer from '../src/ParseServer';
describe('Server Url Checks', () => {
const app = express();
app.get('/health', function(req, res){
res.send('OK');
});
app.listen(13376);
it('validate good server url', (done) => {
Parse.serverURL = 'http://localhost:13376';
ParseServer.verifyServerUrl(function(result) {
if(!result) {
done.fail('Did not pass valid url');
}
done();
});
});
it('mark bad server url', (done) => {
Parse.serverURL = 'notavalidurl';
ParseServer.verifyServerUrl(function(result) {
if(result) {
done.fail('Did not mark invalid url');
}
done();
});
});
});