Fixes for upgraded debian trixie

- Adds request logging in debug mode for some endpoints
- Moves certbot version determination to the startup scripts and removes
  bash script encapsulation when installing plugins
- Revert loose domain validation, which was there for a specific reason
  addressing CVE's
- Fix Cypress suite for cert generation
- Adds Cypress test that iterates over the entire certbot plugins list
  and installs each one, ensuring at the very least that the install
  works
- Fixed some plugins based on this
- (!) Still some work to do on this, hostinger is still broken at least
- Improved cypress tests for custom certs; they will generate on each
  run instead of being baked in. The baked ones were due to expire soon
This commit is contained in:
Jamie Curnow
2026-05-25 07:37:24 +10:00
parent c354238c35
commit 03c70e3902
19 changed files with 197 additions and 49 deletions
+28
View File
@@ -0,0 +1,28 @@
/// <reference types="cypress" />
// Only tested once in the sqlite stack
describe('CertbotPlugins', () => {
it('Should install all certbot plugins', () => {
cy.env(['stack']).then(({ stack }) => {
cy.log(`CertbotPlugins.cy.js - Running tests for stack: ${stack}`);
if (stack === 'sqlite') {
cy.task('backendApiGet', {
path: '/api/ci/certbot-plugins',
}).then((data) => {
expect(data).to.be.an('object');
// Install each plugin
for (const plugin of Object.keys(data)) {
cy.log(`Installing plugin: ${plugin}`);
cy.task('backendApiPost', {
path: `/api/ci/certbot-plugins/${plugin}`,
}).then((result) => {
expect(result).to.be.true;
});
}
});
}
});
});
});
+13 -5
View File
@@ -4,8 +4,16 @@ describe('Certificates endpoints', () => {
let token;
let certID;
const certFile = 'test.example.com.pem';
const keyFile = 'test.example.com-key.pem';
before(() => {
cy.createCustomCerts();
cy.createCustomCerts({
domain: 'test.example.com',
certFile,
keyFile,
})
cy.resetUsers();
cy.getToken().then((tok) => {
token = tok;
@@ -17,8 +25,8 @@ describe('Certificates endpoints', () => {
token: token,
path: '/api/nginx/certificates/validate',
files: {
certificate: 'test.example.com.pem',
certificate_key: 'test.example.com-key.pem',
certificate: certFile,
certificate_key: keyFile,
},
}).then((data) => {
cy.validateSwaggerSchema('post', 200, '/nginx/certificates/validate', data);
@@ -46,8 +54,8 @@ describe('Certificates endpoints', () => {
token: token,
path: `/api/nginx/certificates/${certID}/upload`,
files: {
certificate: 'test.example.com.pem',
certificate_key: 'test.example.com-key.pem',
certificate: certFile,
certificate_key: keyFile,
},
}).then((data) => {
cy.validateSwaggerSchema('post', 200, '/nginx/certificates/{certID}/upload', data);
+11 -13
View File
@@ -3,7 +3,16 @@
describe('Streams', () => {
let token;
const certFile = 'website1.pem';
const keyFile = 'website1.key.pem';
before(() => {
cy.createCustomCerts({
domain: 'website1.example.com',
certFile,
keyFile,
})
cy.resetUsers();
cy.getToken().then((tok) => {
token = tok;
@@ -22,17 +31,6 @@ describe('Streams', () => {
});
});
// Create a custom cert pair
cy.task('getFixturesFolder').then((fixturesFolder) => {
cy.exec(`mkcert -cert-file=${fixturesFolder}/website1.pem -key-file=${fixturesFolder}/website1.key.pem website1.example.com`).then((result) => {
expect(result.exitCode).to.eq(0);
// Install CA
cy.exec('mkcert -install').then((result) => {
expect(result.exitCode).to.eq(0);
});
});
});
cy.exec('rm -f /test/results/testssl.json');
});
@@ -136,8 +134,8 @@ describe('Streams', () => {
token: token,
path: `/api/nginx/certificates/${certID}/upload`,
files: {
certificate: 'website1.pem',
certificate_key: 'website1.key.pem',
certificate: certFile,
certificate_key: keyFile,
},
}).then((data) => {
cy.validateSwaggerSchema('post', 200, '/nginx/certificates/{certID}/upload', data);
+1
View File
@@ -0,0 +1 @@
*.pem
View File
+22 -4
View File
@@ -157,10 +157,28 @@ Cypress.Commands.add('waitForCertificateStatus', (token, certID, expected, timeo
// Creates CA files for testing, if they already exist they will be deleted
// and recreated with the same content. This is to ensure that the files exist
// for testing and are in a known state.
Cypress.Commands.add('createCustomCerts', () => {
cy.task('getFixturesFolder').then((fixturesFolder) => {
cy.exec('mkcert -install', {failOnNonZeroExit: false}).then(() => {
cy.exec(`mkcert -cert-file=${fixturesFolder}/test.example.com.pem -key-file=${fixturesFolder}/test.example.com-key.pem test.example.com`, {failOnNonZeroExit: false});
Cypress.Commands.add('createCustomCerts', ({domain, certFile, keyFile}) => {
domain = domain || 'website1.example.com';
certFile = certFile || 'website1.pem';
keyFile = keyFile || 'website1.key.pem';
return cy.task('getFixturesFolder').then((fixturesFolder) => {
const fullCertFile = `${fixturesFolder}/${certFile}`;
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) => {
cy.log(`mkcert output:\n${JSON.stringify(result)}`);
expect(result.exitCode).to.eq(0);
return cy.exec('mkcert -install').then((result2) => {
cy.log(`mkcert install output:\n${JSON.stringify(result2)}`);
expect(result2.exitCode).to.eq(0);
}).then(() => {
return cy.wrap({
certFile: fullCertFile,
keyFile: fullKeyFile,
});
});
});
});
});