|
|
|
@ -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'); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|