mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-06-17 17:56:27 +00:00
Major update to cypress
- Updated cypress - Ground work for testing DNS certs in CI
This commit is contained in:
@ -9,20 +9,32 @@
|
||||
// ***********************************************
|
||||
//
|
||||
|
||||
import 'cypress-wait-until';
|
||||
|
||||
Cypress.Commands.add('randomString', (length) => {
|
||||
var result = '';
|
||||
var characters = 'ABCDEFGHIJK LMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
var charactersLength = characters.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
||||
/**
|
||||
* Check the swagger schema:
|
||||
*
|
||||
* @param {string} method API Method in swagger doc, "get", "put", "post", "delete"
|
||||
* @param {number} statusCode API status code in swagger doc
|
||||
* @param {integer} code Swagger doc endpoint response code, exactly as defined in swagger doc
|
||||
* @param {string} path Swagger doc endpoint path, exactly as defined in swagger doc
|
||||
* @param {*} data The API response data to check against the swagger schema
|
||||
*/
|
||||
Cypress.Commands.add('validateSwaggerSchema', (method, statusCode, path, data) => {
|
||||
Cypress.Commands.add('validateSwaggerSchema', (method, code, path, data) => {
|
||||
cy.task('validateSwaggerSchema', {
|
||||
file: Cypress.env('swaggerBase'),
|
||||
endpoint: path,
|
||||
method: method,
|
||||
statusCode: statusCode,
|
||||
statusCode: code,
|
||||
responseSchema: data,
|
||||
verbose: true
|
||||
}).should('equal', null);
|
||||
@ -40,3 +52,19 @@ Cypress.Commands.add('getToken', () => {
|
||||
cy.wrap(res.token);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: copied from v3, is this usable?
|
||||
Cypress.Commands.add('waitForCertificateStatus', (token, certID, expected, timeout = 60) => {
|
||||
cy.log(`Waiting for certificate (${certID}) status (${expected}) timeout (${timeout})`);
|
||||
|
||||
cy.waitUntil(() => cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: `/api/certificates/${certID}`
|
||||
}).then((data) => {
|
||||
return data.result.status === expected;
|
||||
}), {
|
||||
errorMsg: 'Waiting for certificate status failed',
|
||||
timeout: timeout * 1000,
|
||||
interval: 5000
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user