Browse Source

removed support for api.pipService (relocated to api.services)

pull/875/head
Stephen Hess 7 years ago
parent
commit
aa09419b9c
  1. 2
      schema.js
  2. 62
      test/unit/schema.js

2
schema.js

@ -26,7 +26,7 @@ module.exports = Joi.object().keys({
localization: Joi.object().keys({
flipNumberAndStreetCountries: Joi.array().items(Joi.string().regex(/^[A-Z]{3}$/))
}).unknown(false),
pipService: Joi.string().uri({ scheme: /https?/ }),
pipService: Joi.any().forbidden(), // got moved to services
placeholderService: Joi.any().forbidden(), // got moved to services
services: Joi.object().keys({
pip: Joi.object().keys({

62
test/unit/schema.js

@ -407,37 +407,15 @@ module.exports.tests.api_validation = (test, common) => {
});
test('non-string api.pipService should throw error', (t) => {
[null, 17, {}, [], true].forEach((value) => {
var config = {
api: {
version: 'version value',
indexName: 'index name value',
host: 'host value',
pipService: value
},
esclient: {}
};
const result = Joi.validate(config, schema);
t.equals(result.error.details.length, 1);
t.equals(result.error.details[0].message, '"pipService" must be a string');
});
t.end();
});
test('non-http/https api.pipService should throw error', (t) => {
['ftp', 'git', 'unknown'].forEach((scheme) => {
// api.placeholderService has been moved to api.services.placeholder.url
test('any api.placeholderService value should be disallowed', (t) => {
[null, 17, {}, [], true, 'http://localhost'].forEach((value) => {
var config = {
api: {
version: 'version value',
indexName: 'index name value',
host: 'host value',
pipService: `${scheme}://localhost`
placeholderService: value
},
esclient: {}
};
@ -445,29 +423,7 @@ module.exports.tests.api_validation = (test, common) => {
const result = Joi.validate(config, schema);
t.equals(result.error.details.length, 1);
t.equals(result.error.details[0].message, '"pipService" must be a valid uri with a scheme matching the https? pattern');
});
t.end();
});
test('http/https api.pipService should not throw error', (t) => {
['http', 'https'].forEach((scheme) => {
var config = {
api: {
version: 'version value',
indexName: 'index name value',
host: 'host value',
pipService: `${scheme}://localhost`
},
esclient: {}
};
const result = Joi.validate(config, schema);
t.notOk(result.error);
t.equals(result.error.details[0].message, '"placeholderService" is not allowed');
});
@ -475,15 +431,15 @@ module.exports.tests.api_validation = (test, common) => {
});
// api.placeholderService has been moved to api.services.placeholder.url
test('any api.placeholderService value should be disallowed', (t) => {
// api.pipService has been moved to api.services.pip.url
test('any api.pipService value should be disallowed', (t) => {
[null, 17, {}, [], true, 'http://localhost'].forEach((value) => {
var config = {
api: {
version: 'version value',
indexName: 'index name value',
host: 'host value',
placeholderService: value
pipService: value
},
esclient: {}
};
@ -491,7 +447,7 @@ module.exports.tests.api_validation = (test, common) => {
const result = Joi.validate(config, schema);
t.equals(result.error.details.length, 1);
t.equals(result.error.details[0].message, '"placeholderService" is not allowed');
t.equals(result.error.details[0].message, '"pipService" is not allowed');
});

Loading…
Cancel
Save