mirror of
https://github.com/smartyellow/status.git
synced 2025-01-18 05:27:58 +00:00
Autotest validation
This commit is contained in:
parent
58dec27b0e
commit
150c762379
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { makeId } = require('core/makeid');
|
const { makeId } = require('core/makeid');
|
||||||
|
const { url } = require('core/types');
|
||||||
|
|
||||||
const states = {
|
const states = {
|
||||||
concept: 'concept',
|
concept: 'concept',
|
||||||
@ -346,6 +347,42 @@ module.exports = {
|
|||||||
|
|
||||||
autotest: {
|
autotest: {
|
||||||
default: [],
|
default: [],
|
||||||
|
type: 'array',
|
||||||
|
validate: ({ newValues }) => {
|
||||||
|
if (newValues.autotest && !Array.isArray(newValues.autotest)) {
|
||||||
|
return 'autotest must be an array';
|
||||||
|
}
|
||||||
|
else if (newValues.autotest) {
|
||||||
|
for (const [ iEndpoint, endpoint ] of newValues.autotest.entries()) {
|
||||||
|
if (!url.test(endpoint.uri)) {
|
||||||
|
return 'not a valid url';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Array.isArray(endpoint.headers)) {
|
||||||
|
return 'endpoint headers must be an array';
|
||||||
|
}
|
||||||
|
|
||||||
|
const foundHeaders = [];
|
||||||
|
for (const header of endpoint.headers) {
|
||||||
|
if (foundHeaders.includes(header.name)) {
|
||||||
|
return 'found duplicate headers in endpoint #' + iEndpoint;
|
||||||
|
}
|
||||||
|
else if (!header.name || !header.name.trim || !header.name.trim()) {
|
||||||
|
return 'empty header name in endpoint #' + iEndpoint;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
foundHeaders.push(header.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Array.isArray(endpoint.requirements)) {
|
||||||
|
return 'requirements must be an object';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
outages: {
|
outages: {
|
||||||
|
Loading…
Reference in New Issue
Block a user