mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2026-11-10 12:28:28 +00:00
Migrate cypress to v16
This commit is contained in:
1 parent
1c76fb76ea
commit
ec0f30106d
5 files changed
+38
-9
No files matched your search
@@ -25,7 +25,7 @@ describe('Access Lists across Proxy Host disable/enable', () => {
|
||||
*/
|
||||
const request = (auth) => {
|
||||
const authArg = auth ? `-u '${auth.username}:${auth.password}'` : '';
|
||||
return cy.exec(`curl --noproxy '*' -s -o /dev/null -w '%{http_code}' ${authArg} http://${domain}/`)
|
||||
return cy.task('exec', { command: `curl --noproxy '*' -s -o /dev/null -w '%{http_code}' ${authArg} http://${domain}/` }, { log: false })
|
||||
.then((result) => {
|
||||
expect(result.exitCode).to.eq(0);
|
||||
return result.stdout.trim();
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('Per-path Access Lists', () => {
|
||||
*/
|
||||
const request = (path, creds) => {
|
||||
const auth = creds ? `-u '${creds.username}:${creds.password}'` : '';
|
||||
return cy.exec(`curl --noproxy '*' -s -w '\n%{http_code}' ${auth} http://${domain}${path}`)
|
||||
return cy.task('exec', { command: `curl --noproxy '*' -s -w '\n%{http_code}' ${auth} http://${domain}${path}` }, { log: false })
|
||||
.then((result) => {
|
||||
expect(result.exitCode).to.eq(0);
|
||||
const lines = result.stdout.trim().split('\n');
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('Streams', () => {
|
||||
});
|
||||
});
|
||||
|
||||
cy.exec('rm -f /test/results/testssl.json');
|
||||
cy.task('exec', { command: 'rm -f /test/results/testssl.json' });
|
||||
});
|
||||
|
||||
it('Should be able to create TCP Stream', () => {
|
||||
@@ -55,7 +55,7 @@ describe('Streams', () => {
|
||||
expect(data).to.have.property('tcp_forwarding', true);
|
||||
expect(data).to.have.property('udp_forwarding', false);
|
||||
|
||||
cy.exec('curl --noproxy -- http://website1.example.com:1500').then((result) => {
|
||||
cy.task('exec', { command: 'curl --noproxy -- http://website1.example.com:1500' }).then((result) => {
|
||||
expect(result.exitCode).to.eq(0);
|
||||
expect(result.stdout).to.contain('yay it works');
|
||||
});
|
||||
@@ -106,7 +106,7 @@ describe('Streams', () => {
|
||||
expect(data).to.have.property('tcp_forwarding', true);
|
||||
expect(data).to.have.property('udp_forwarding', true);
|
||||
|
||||
cy.exec('curl --noproxy -- http://website1.example.com:1502').then((result) => {
|
||||
cy.task('exec', { command: 'curl --noproxy -- http://website1.example.com:1502' }).then((result) => {
|
||||
expect(result.exitCode).to.eq(0);
|
||||
expect(result.stdout).to.contain('yay it works');
|
||||
});
|
||||
@@ -166,7 +166,9 @@ describe('Streams', () => {
|
||||
|
||||
// Check the ssl termination
|
||||
cy.task('log', '[testssl.sh] Running ...');
|
||||
cy.exec('/testssl/testssl.sh --quiet --add-ca="$(/bin/mkcert -CAROOT)/rootCA.pem" --jsonfile=/test/results/testssl.json website1.example.com:1503', {
|
||||
cy.task('exec', {
|
||||
command: '/testssl/testssl.sh --quiet --add-ca="$(/bin/mkcert -CAROOT)/rootCA.pem" --jsonfile=/test/results/testssl.json website1.example.com:1503',
|
||||
}, {
|
||||
timeout: 120000, // 2 minutes
|
||||
}).then((result) => {
|
||||
cy.task('log', `[testssl.sh] ${result.stdout}`);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { plugin as cypressGrepPlugin } from "@cypress/grep/plugin";
|
||||
import { SwaggerValidation } from "@jc21/cypress-swagger-validation";
|
||||
import { exec } from "node:child_process";
|
||||
import chalk from "chalk";
|
||||
import backendTask from "./backendApi/task.mjs";
|
||||
|
||||
@@ -25,6 +26,32 @@ export default (on, config) => {
|
||||
return null;
|
||||
},
|
||||
});
|
||||
on("task", {
|
||||
/**
|
||||
* Replacement for cy.exec(), removed in Cypress 16
|
||||
*
|
||||
* @param {object} options
|
||||
* @param {string} options.command
|
||||
* @param {bool} [options.failOnNonZeroExit] Defaults to true
|
||||
* @returns {object} { exitCode, stdout, stderr }
|
||||
*/
|
||||
exec({ command, failOnNonZeroExit = true }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(command, { maxBuffer: 10 * 1024 * 1024 }, (error, stdout, stderr) => {
|
||||
const result = {
|
||||
exitCode: error ? (error.code ?? 1) : 0,
|
||||
stdout: stdout.trimEnd(),
|
||||
stderr: stderr.trimEnd(),
|
||||
};
|
||||
if (error && failOnNonZeroExit) {
|
||||
reject(new Error(`Command failed with exit code ${result.exitCode}: ${command}\n${result.stderr}`));
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
on("task", {
|
||||
getFixturesFolder() {
|
||||
return config.fixturesFolder;
|
||||
|
||||
@@ -33,7 +33,7 @@ Cypress.Commands.add("validateSwaggerFile", (url, savePath) => {
|
||||
return cy
|
||||
.request(url)
|
||||
.then((response) => cy.writeFile(savePath, response.body, { log: false }))
|
||||
.then(() => cy.exec(`yarn swagger-lint '${savePath}'`, { failOnNonZeroExit: false }))
|
||||
.then(() => cy.task('exec', { command: `yarn swagger-lint '${savePath}'`, failOnNonZeroExit: false }))
|
||||
.then((result) => cy.task('log', `Swagger Vacuum Results:\n${result.stdout || ''}`)
|
||||
.then(() => expect(result.exitCode).to.eq(0)));
|
||||
});
|
||||
@@ -167,10 +167,10 @@ Cypress.Commands.add('createCustomCerts', ({domain, certFile, keyFile}) => {
|
||||
const fullKeyFile = `${fixturesFolder}/${keyFile}`;
|
||||
const cmd = `mkcert -cert-file="${fullCertFile}" -key-file="${fullKeyFile}" "${domain}"`;
|
||||
cy.log(`Creating custom certs with command: ${cmd}`);
|
||||
return cy.exec(cmd).then((result) => {
|
||||
return cy.task('exec', { command: cmd }).then((result) => {
|
||||
cy.log(`mkcert output:\n${JSON.stringify(result)}`);
|
||||
expect(result.exitCode).to.eq(0);
|
||||
return cy.exec('mkcert -install').then((result2) => {
|
||||
return cy.task('exec', { command: 'mkcert -install' }).then((result2) => {
|
||||
cy.log(`mkcert install output:\n${JSON.stringify(result2)}`);
|
||||
expect(result2.exitCode).to.eq(0);
|
||||
}).then(() => {
|
||||
|
||||
Reference in new issue
Block a user