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

+10
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

+2-2
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

+1-1
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

-22
This file was deleted.

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

+18-16
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

+2-2
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

test/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "index.js",
66
"dependencies": {
7-
"@jc21/cypress-swagger-validation": "^0.2.8",
7+
"@jc21/cypress-swagger-validation": "^0.3.1",
88
"axios": "^1.7.7",
99
"cypress": "^13.15.0",
1010
"cypress-multi-reporters": "^1.6.4",
@@ -19,8 +19,8 @@
1919
"mocha-junit-reporter": "^2.2.1"
2020
},
2121
"scripts": {
22-
"cypress": "HTTP_PROXY=127.0.0.1:8128 HTTPS_PROXY=127.0.0.1:8128 cypress open --config-file=cypress/config/dev.js",
23-
"cypress:headless": "HTTP_PROXY=127.0.0.1:8128 HTTPS_PROXY=127.0.0.1:8128 cypress run --config-file=cypress/config/dev.js"
22+
"cypress": "HTTP_PROXY=127.0.0.1:8128 HTTPS_PROXY=127.0.0.1:8128 cypress open --config-file=cypress/config/ci.js",
23+
"cypress:headless": "HTTP_PROXY=127.0.0.1:8128 HTTPS_PROXY=127.0.0.1:8128 cypress run --config-file=cypress/config/ci.js"
2424
},
2525
"author": "",
2626
"license": "ISC"

test/yarn.lock

+12-19
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
call-me-maybe "^1.0.1"
1212
js-yaml "^3.13.1"
1313

14-
"@apidevtools/json-schema-ref-parser@9.0.9":
15-
version "9.0.9"
16-
resolved "https://registry.yarnpkg.com/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz#d720f9256e3609621280584f2b47ae165359268b"
17-
integrity sha512-GBD2Le9w2+lVFoc4vswGI/TjkNIZSVp7+9xPf+X3uidBfWnAeUWmquteSyt0+VCrhNMWj/FTABISQrD3Z/YA+w==
14+
"@apidevtools/json-schema-ref-parser@^11.7.2":
15+
version "11.7.2"
16+
resolved "https://registry.yarnpkg.com/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-11.7.2.tgz#cdf3e0aded21492364a70e193b45b7cf4177f031"
17+
integrity sha512-4gY54eEGEstClvEkGnwVkTkrx0sqwemEFG5OSRRn3tD91XH0+Q8XIkYIfo7IwEWPpJZwILb9GUXeShtplRc/eA==
1818
dependencies:
1919
"@jsdevtools/ono" "^7.1.3"
20-
"@types/json-schema" "^7.0.6"
21-
call-me-maybe "^1.0.1"
20+
"@types/json-schema" "^7.0.15"
2221
js-yaml "^4.1.0"
2322

2423
"@apidevtools/openapi-schemas@^2.1.0":
@@ -167,15 +166,16 @@
167166
resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.3.1.tgz#c72a5c76a9fbaf3488e231b13dc52c0da7bab42a"
168167
integrity sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==
169168

170-
"@jc21/cypress-swagger-validation@^0.2.8":
171-
version "0.2.8"
172-
resolved "https://registry.yarnpkg.com/@jc21/cypress-swagger-validation/-/cypress-swagger-validation-0.2.8.tgz#8ab059bd41e3ee100a1998a1484b9e5a2e9a4224"
173-
integrity sha512-9fiZIHj3//bJjC5YUMOc42RnoEUeeokVn6xtMnP52XIZ/ryWQ9PIyFdlOAH8q/LW/uPxozJo2+hdB6ou4iurag==
169+
"@jc21/cypress-swagger-validation@^0.3.1":
170+
version "0.3.1"
171+
resolved "https://registry.yarnpkg.com/@jc21/cypress-swagger-validation/-/cypress-swagger-validation-0.3.1.tgz#1cdd49850a20f876ed62149623f99988264751be"
172+
integrity sha512-Vdt1gLfj8p0tJhA42Cfn43XBbsKocNfVCEVSwkn7RmZgWUyRKjqhBBRTVa9cKZTozyg8Co/yhBMsNyjmHFVXtQ==
174173
dependencies:
174+
"@apidevtools/json-schema-ref-parser" "^11.7.2"
175175
"@apidevtools/swagger-parser" "^10.1.0"
176176
ajv "^8.17.1"
177+
axios "^1.7.7"
177178
json-schema "^0.4.0"
178-
json-schema-ref-parser "^9.0.9"
179179
jsonpath "^1.1.1"
180180
lodash "^4.17.21"
181181
openapi-types "^12.1.3"
@@ -196,7 +196,7 @@
196196
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50"
197197
integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==
198198

199-
"@types/json-schema@^7.0.15", "@types/json-schema@^7.0.6":
199+
"@types/json-schema@^7.0.15":
200200
version "7.0.15"
201201
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
202202
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==
@@ -1468,13 +1468,6 @@ json-buffer@3.0.1:
14681468
resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13"
14691469
integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==
14701470

1471-
json-schema-ref-parser@^9.0.9:
1472-
version "9.0.9"
1473-
resolved "https://registry.yarnpkg.com/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz#66ea538e7450b12af342fa3d5b8458bc1e1e013f"
1474-
integrity sha512-qcP2lmGy+JUoQJ4DOQeLaZDqH9qSkeGCK3suKWxJXS82dg728Mn3j97azDMaOUmJAN4uCq91LdPx4K7E8F1a7Q==
1475-
dependencies:
1476-
"@apidevtools/json-schema-ref-parser" "9.0.9"
1477-
14781471
json-schema-traverse@^0.4.1:
14791472
version "0.4.1"
14801473
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"

0 commit comments

Comments
 (0)