Updated swagger cypress package,

which works with proxies
This commit is contained in:
Jamie Curnow
2024-10-15 23:54:39 +10:00
parent 351ba8dacd
commit f48e1b46a8
12 changed files with 52 additions and 69 deletions

View File

@ -15,7 +15,7 @@ module.exports = defineConfig({
return require("../plugins/index.js")(on, config);
},
env: {
swaggerBase: 'http://fullstack:81/api/schema',
swaggerBase: '{{baseUrl}}/api/schema?ts=' + Date.now(),
},
baseUrl: 'http://fullstack:81',
}

View File

@ -1,22 +0,0 @@
const { defineConfig } = require('cypress');
module.exports = defineConfig({
requestTimeout: 30000,
defaultCommandTimeout: 20000,
reporter: 'cypress-multi-reporters',
reporterOptions: {
configFile: 'multi-reporter.json'
},
video: false,
videosFolder: 'results/videos',
screenshotsFolder: 'results/screenshots',
e2e: {
setupNodeEvents(on, config) {
return require("../plugins/index.js")(on, config);
},
env: {
swaggerBase: 'http://npm:81/api/schema',
},
baseUrl: 'http://npm:81',
}
});

View File

@ -1,4 +1,4 @@
/// <reference types="Cypress" />
/// <reference types="cypress" />
describe('Certificates endpoints', () => {
let token;
@ -26,6 +26,7 @@ describe('Certificates endpoints', () => {
});
it('Custom certificate lifecycle', function() {
// Create custom cert
cy.task('backendApiPost', {
token: token,
path: '/api/nginx/certificates',
@ -38,6 +39,7 @@ describe('Certificates endpoints', () => {
expect(data).to.have.property('id');
certID = data.id;
// Upload files
cy.task('backendApiPostFiles', {
token: token,
path: `/api/nginx/certificates/${certID}/upload`,
@ -46,31 +48,31 @@ describe('Certificates endpoints', () => {
certificate_key: 'test.example.com-key.pem',
},
}).then((data) => {
cy.validateSwaggerSchema('post', 201, '/nginx/certificates/upload', data);
cy.validateSwaggerSchema('post', 200, '/nginx/certificates/{certID}/upload', data);
expect(data).to.have.property('certificate');
expect(data).to.have.property('certificate_key');
cy.task('backendApiDelete', {
// Get all certs
cy.task('backendApiGet', {
token: token,
path: `/api/nginx/certificates/${certID}`
path: '/api/nginx/certificates?expand=owner'
}).then((data) => {
cy.validateSwaggerSchema('delete', 200, '/nginx/certificates/{certID}', data);
expect(data).to.be.equal(true);
cy.validateSwaggerSchema('get', 200, '/nginx/certificates', data);
expect(data.length).to.be.greaterThan(0);
// Delete cert
cy.task('backendApiDelete', {
token: token,
path: `/api/nginx/certificates/${certID}`
}).then((data) => {
cy.validateSwaggerSchema('delete', 200, '/nginx/certificates/{certID}', data);
expect(data).to.be.equal(true);
});
});
});
});
});
it('Should be able to get all certs', function() {
cy.task('backendApiGet', {
token: token,
path: '/api/nginx/certificates?expand=owner'
}).then((data) => {
cy.validateSwaggerSchema('get', 200, '/nginx/certificates', data);
expect(data.length).to.be.greaterThan(0);
});
});
it('Request Certificate - CVE-2024-46256/CVE-2024-46257', function() {
cy.task('backendApiPost', {
token: token,

View File

@ -1,4 +1,4 @@
/// <reference types="Cypress" />
/// <reference types="cypress" />
describe('Basic API checks', () => {
it('Should return a valid health payload', function () {
@ -12,7 +12,7 @@ describe('Basic API checks', () => {
it('Should return a valid schema payload', function () {
cy.task('backendApiGet', {
path: '/api/schema',
path: '/api/schema?ts=' + Date.now(),
}).then((data) => {
expect(data.openapi).to.be.equal('3.1.0');
});

View File

@ -1,4 +1,4 @@
/// <reference types="Cypress" />
/// <reference types="cypress" />
describe('Hosts endpoints', () => {
let token;

View File

@ -1,4 +1,4 @@
/// <reference types="Cypress" />
/// <reference types="cypress" />
describe('Users endpoints', () => {
let token;

View File

@ -80,7 +80,7 @@ BackendApi.prototype._handleError = function(err, resolve, reject, returnOnError
* @returns {Promise<object>}
*/
BackendApi.prototype.request = function (method, path, returnOnError, data) {
logger(method.toUpperCase(), this.config.baseUrl + path);
logger(method.toUpperCase(), path);
const options = this._prepareOptions(returnOnError);
return new Promise((resolve, reject) => {

View File

@ -1,4 +1,4 @@
const {SwaggerValidation} = require('@jc21/cypress-swagger-validation');
const { SwaggerValidation } = require('@jc21/cypress-swagger-validation');
module.exports = (on, config) => {
// Replace swaggerBase config var wildcard