|
|
@ -523,6 +523,85 @@ module.exports.tests.api_services_validation = (test, common) => { |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports.tests.placeholder_service_validation = (test, common) => { |
|
|
|
|
|
|
|
test('when api.services.placeholder is defined, url is required', (t) => { |
|
|
|
|
|
|
|
var config = { |
|
|
|
|
|
|
|
api: { |
|
|
|
|
|
|
|
version: 'version value', |
|
|
|
|
|
|
|
indexName: 'index name value', |
|
|
|
|
|
|
|
host: 'host value', |
|
|
|
|
|
|
|
services: { |
|
|
|
|
|
|
|
placeholder: { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
esclient: {} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = Joi.validate(config, schema); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.equals(result.error.details.length, 1); |
|
|
|
|
|
|
|
t.equals(result.error.details[0].message, '"url" is required'); |
|
|
|
|
|
|
|
t.end(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('non-string api.services.placeholder.url should throw error', (t) => { |
|
|
|
|
|
|
|
[null, 17, {}, [], true].forEach((value) => { |
|
|
|
|
|
|
|
var config = { |
|
|
|
|
|
|
|
api: { |
|
|
|
|
|
|
|
version: 'version value', |
|
|
|
|
|
|
|
indexName: 'index name value', |
|
|
|
|
|
|
|
host: 'host value', |
|
|
|
|
|
|
|
services: { |
|
|
|
|
|
|
|
placeholder: { |
|
|
|
|
|
|
|
url: value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
esclient: {} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = Joi.validate(config, schema); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.equals(result.error.details.length, 1); |
|
|
|
|
|
|
|
t.equals(result.error.details[0].message, '"url" must be a string'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.end(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('non-http/https api.services.placeholder.url should throw error', (t) => { |
|
|
|
|
|
|
|
['ftp', 'git', 'unknown'].forEach((scheme) => { |
|
|
|
|
|
|
|
var config = { |
|
|
|
|
|
|
|
api: { |
|
|
|
|
|
|
|
version: 'version value', |
|
|
|
|
|
|
|
indexName: 'index name value', |
|
|
|
|
|
|
|
host: 'host value', |
|
|
|
|
|
|
|
services: { |
|
|
|
|
|
|
|
placeholder: { |
|
|
|
|
|
|
|
url: `${scheme}://localhost` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
esclient: {} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = Joi.validate(config, schema); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.equals(result.error.details.length, 1); |
|
|
|
|
|
|
|
t.equals(result.error.details[0].message, '"url" must be a valid uri with a scheme matching the https\? pattern'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.end(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('non-url children of api.services.placeholder should be disallowed', (t) => { |
|
|
|
test('non-url children of api.services.placeholder should be disallowed', (t) => { |
|
|
|
var config = { |
|
|
|
var config = { |
|
|
|
api: { |
|
|
|
api: { |
|
|
@ -547,14 +626,17 @@ module.exports.tests.api_services_validation = (test, common) => { |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('when api.services.placeholder is defined, url is required', (t) => { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports.tests.pip_service_validation = (test, common) => { |
|
|
|
|
|
|
|
test('when api.services.pip is defined, url is required', (t) => { |
|
|
|
var config = { |
|
|
|
var config = { |
|
|
|
api: { |
|
|
|
api: { |
|
|
|
version: 'version value', |
|
|
|
version: 'version value', |
|
|
|
indexName: 'index name value', |
|
|
|
indexName: 'index name value', |
|
|
|
host: 'host value', |
|
|
|
host: 'host value', |
|
|
|
services: { |
|
|
|
services: { |
|
|
|
placeholder: { |
|
|
|
pip: { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
@ -569,7 +651,7 @@ module.exports.tests.api_services_validation = (test, common) => { |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('non-string api.services.placeholder.url should throw error', (t) => { |
|
|
|
test('non-string api.services.pip.url should throw error', (t) => { |
|
|
|
[null, 17, {}, [], true].forEach((value) => { |
|
|
|
[null, 17, {}, [], true].forEach((value) => { |
|
|
|
var config = { |
|
|
|
var config = { |
|
|
|
api: { |
|
|
|
api: { |
|
|
@ -577,7 +659,7 @@ module.exports.tests.api_services_validation = (test, common) => { |
|
|
|
indexName: 'index name value', |
|
|
|
indexName: 'index name value', |
|
|
|
host: 'host value', |
|
|
|
host: 'host value', |
|
|
|
services: { |
|
|
|
services: { |
|
|
|
placeholder: { |
|
|
|
pip: { |
|
|
|
url: value |
|
|
|
url: value |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -596,7 +678,7 @@ module.exports.tests.api_services_validation = (test, common) => { |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('non-http/https api.services.placeholder.url should throw error', (t) => { |
|
|
|
test('non-http/https api.services.pip.url should throw error', (t) => { |
|
|
|
['ftp', 'git', 'unknown'].forEach((scheme) => { |
|
|
|
['ftp', 'git', 'unknown'].forEach((scheme) => { |
|
|
|
var config = { |
|
|
|
var config = { |
|
|
|
api: { |
|
|
|
api: { |
|
|
@ -604,7 +686,7 @@ module.exports.tests.api_services_validation = (test, common) => { |
|
|
|
indexName: 'index name value', |
|
|
|
indexName: 'index name value', |
|
|
|
host: 'host value', |
|
|
|
host: 'host value', |
|
|
|
services: { |
|
|
|
services: { |
|
|
|
placeholder: { |
|
|
|
pip: { |
|
|
|
url: `${scheme}://localhost` |
|
|
|
url: `${scheme}://localhost` |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -623,14 +705,14 @@ module.exports.tests.api_services_validation = (test, common) => { |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('non-url children of api.services.placeholder should be disallowed', (t) => { |
|
|
|
test('non-url children of api.services.pip should be disallowed', (t) => { |
|
|
|
var config = { |
|
|
|
var config = { |
|
|
|
api: { |
|
|
|
api: { |
|
|
|
version: 'version value', |
|
|
|
version: 'version value', |
|
|
|
indexName: 'index name value', |
|
|
|
indexName: 'index name value', |
|
|
|
host: 'host value', |
|
|
|
host: 'host value', |
|
|
|
services: { |
|
|
|
services: { |
|
|
|
placeholder: { |
|
|
|
pip: { |
|
|
|
url: 'http://localhost', |
|
|
|
url: 'http://localhost', |
|
|
|
unknown_property: 'value' |
|
|
|
unknown_property: 'value' |
|
|
|
} |
|
|
|
} |
|
|
|