Browse Source

added placeholderService to schema

pull/850/head
Stephen Hess 8 years ago
parent
commit
94f512fe94
  1. 3
      schema.js
  2. 80
      test/unit/schema.js

3
schema.js

@ -26,7 +26,8 @@ module.exports = Joi.object().keys({
localization: Joi.object().keys({ localization: Joi.object().keys({
flipNumberAndStreetCountries: Joi.array().items(Joi.string().regex(/^[A-Z]{3}$/)) flipNumberAndStreetCountries: Joi.array().items(Joi.string().regex(/^[A-Z]{3}$/))
}).unknown(false), }).unknown(false),
pipService: Joi.string().uri({ scheme: /https?/ }) pipService: Joi.string().uri({ scheme: /https?/ }),
placeholderService: Joi.string().uri({ scheme: /https?/ })
}).requiredKeys('version', 'indexName', 'host').unknown(true), }).requiredKeys('version', 'indexName', 'host').unknown(true),
esclient: Joi.object().keys({ esclient: Joi.object().keys({

80
test/unit/schema.js

@ -447,6 +447,86 @@ module.exports.tests.api_validation = (test, common) => {
}); });
test('non-string api.placeholderService should throw error', (t) => {
[null, 17, {}, [], true].forEach((value) => {
var config = {
api: {
version: 'version value',
indexName: 'index name value',
host: 'host value',
placeholderService: value
},
esclient: {}
};
t.throws(validate.bind(null, config), /"placeholderService" must be a string/);
});
t.end();
});
test('non-URI-formatted api.placeholderService should throw error', (t) => {
['this is not a URI'].forEach((value) => {
var config = {
api: {
version: 'version value',
indexName: 'index name value',
host: 'host value',
placeholderService: value
},
esclient: {}
};
t.throws(validate.bind(null, config), /"placeholderService" must be a valid uri/);
});
t.end();
});
test('non-http/https api.placeholderService should throw error', (t) => {
['ftp', 'git', 'unknown'].forEach((scheme) => {
var config = {
api: {
version: 'version value',
indexName: 'index name value',
host: 'host value',
placeholderService: `${scheme}://localhost`
},
esclient: {}
};
t.throws(validate.bind(null, config), /"placeholderService" must be a valid uri/);
});
t.end();
});
test('http/https api.placeholderService should not throw error', (t) => {
['http', 'https'].forEach((scheme) => {
var config = {
api: {
version: 'version value',
indexName: 'index name value',
host: 'host value',
placeholderService: `${scheme}://localhost`
},
esclient: {}
};
t.doesNotThrow(validate.bind(null, config), `${scheme} should be allowed`);
});
t.end();
});
}; };
module.exports.tests.esclient_validation = (test, common) => { module.exports.tests.esclient_validation = (test, common) => {

Loading…
Cancel
Save