Skip to content

Commit f48e1b4

Browse files
committed
Updated swagger cypress package,
which works with proxies
1 parent 351ba8d commit f48e1b4

File tree

12 files changed

+52
-69
lines changed

12 files changed

+52
-69
lines changed

Jenkinsfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ pipeline {
127127
junit 'test/results/junit/*'
128128
sh 'docker-compose down --remove-orphans --volumes -t 30 || true'
129129
}
130+
unstable {
131+
dir(path: 'testing/results') {
132+
archiveArtifacts(allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml')
133+
}
134+
}
130135
}
131136
}
132137
stage('Test Mysql') {
@@ -155,6 +160,11 @@ pipeline {
155160
junit 'test/results/junit/*'
156161
sh 'docker-compose down --remove-orphans --volumes -t 30 || true'
157162
}
163+
unstable {
164+
dir(path: 'testing/results') {
165+
archiveArtifacts(allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml')
166+
}
167+
}
158168
}
159169
}
160170
stage('MultiArch Build') {

docker/docker-compose.dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# WARNING: This is a DEVELOPMENT docker-compose file, it should not be used for production.
22
services:
33

4-
npm:
4+
fullstack:
55
image: nginxproxymanager:dev
66
container_name: npm_core
77
build:
@@ -67,7 +67,7 @@ services:
6767
URL: "http://npm:81/api/schema"
6868
PORT: '80'
6969
depends_on:
70-
- npm
70+
- fullstack
7171

7272
squid:
7373
image: ubuntu/squid

test/cypress/config/ci.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = defineConfig({
1515
return require("../plugins/index.js")(on, config);
1616
},
1717
env: {
18-
swaggerBase: 'http://fullstack:81/api/schema',
18+
swaggerBase: '{{baseUrl}}/api/schema?ts=' + Date.now(),
1919
},
2020
baseUrl: 'http://fullstack:81',
2121
}

test/cypress/config/dev.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

test/cypress/e2e/api/Certificates.cy.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference types="Cypress" />
1+
/// <reference types="cypress" />
22

33
describe('Certificates endpoints', () => {
44
let token;
@@ -26,6 +26,7 @@ describe('Certificates endpoints', () => {
2626
});
2727

2828
it('Custom certificate lifecycle', function() {
29+
// Create custom cert
2930
cy.task('backendApiPost', {
3031
token: token,
3132
path: '/api/nginx/certificates',
@@ -38,6 +39,7 @@ describe('Certificates endpoints', () => {
3839
expect(data).to.have.property('id');
3940
certID = data.id;
4041

42+
// Upload files
4143
cy.task('backendApiPostFiles', {
4244
token: token,
4345
path: `/api/nginx/certificates/${certID}/upload`,
@@ -46,31 +48,31 @@ describe('Certificates endpoints', () => {
4648
certificate_key: 'test.example.com-key.pem',
4749
},
4850
}).then((data) => {
49-
cy.validateSwaggerSchema('post', 201, '/nginx/certificates/upload', data);
51+
cy.validateSwaggerSchema('post', 200, '/nginx/certificates/{certID}/upload', data);
5052
expect(data).to.have.property('certificate');
5153
expect(data).to.have.property('certificate_key');
5254

53-
cy.task('backendApiDelete', {
55+
// Get all certs
56+
cy.task('backendApiGet', {
5457
token: token,
55-
path: `/api/nginx/certificates/${certID}`
58+
path: '/api/nginx/certificates?expand=owner'
5659
}).then((data) => {
57-
cy.validateSwaggerSchema('delete', 200, '/nginx/certificates/{certID}', data);
58-
expect(data).to.be.equal(true);
60+
cy.validateSwaggerSchema('get', 200, '/nginx/certificates', data);
61+
expect(data.length).to.be.greaterThan(0);
62+
63+
// Delete cert
64+
cy.task('backendApiDelete', {
65+
token: token,
66+
path: `/api/nginx/certificates/${certID}`
67+
}).then((data) => {
68+
cy.validateSwaggerSchema('delete', 200, '/nginx/certificates/{certID}', data);
69+
expect(data).to.be.equal(true);
70+
});
5971
});
6072
});
6173
});
6274
});
6375

64-
it('Should be able to get all certs', function() {
65-
cy.task('backendApiGet', {
66-
token: token,
67-
path: '/api/nginx/certificates?expand=owner'
68-
}).then((data) => {
69-
cy.validateSwaggerSchema('get', 200, '/nginx/certificates', data);
70-
expect(data.length).to.be.greaterThan(0);
71-
});
72-
});
73-
7476
it('Request Certificate - CVE-2024-46256/CVE-2024-46257', function() {
7577
cy.task('backendApiPost', {
7678
token: token,

test/cypress/e2e/api/Health.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference types="Cypress" />
1+
/// <reference types="cypress" />
22

33
describe('Basic API checks', () => {
44
it('Should return a valid health payload', function () {
@@ -12,7 +12,7 @@ describe('Basic API checks', () => {
1212

1313
it('Should return a valid schema payload', function () {
1414
cy.task('backendApiGet', {
15-
path: '/api/schema',
15+
path: '/api/schema?ts=' + Date.now(),
1616
}).then((data) => {
1717
expect(data.openapi).to.be.equal('3.1.0');
1818
});

test/cypress/e2e/api/Hosts.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference types="Cypress" />
1+
/// <reference types="cypress" />
22

33
describe('Hosts endpoints', () => {
44
let token;

test/cypress/e2e/api/Users.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference types="Cypress" />
1+
/// <reference types="cypress" />
22

33
describe('Users endpoints', () => {
44
let token;

test/cypress/plugins/backendApi/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ BackendApi.prototype._handleError = function(err, resolve, reject, returnOnError
8080
* @returns {Promise<object>}
8181
*/
8282
BackendApi.prototype.request = function (method, path, returnOnError, data) {
83-
logger(method.toUpperCase(), this.config.baseUrl + path);
83+
logger(method.toUpperCase(), path);
8484
const options = this._prepareOptions(returnOnError);
8585

8686
return new Promise((resolve, reject) => {

test/cypress/plugins/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {SwaggerValidation} = require('@jc21/cypress-swagger-validation');
1+
const { SwaggerValidation } = require('@jc21/cypress-swagger-validation');
22

33
module.exports = (on, config) => {
44
// Replace swaggerBase config var wildcard

0 commit comments

Comments
 (0)