Add test for certificate validation with view-only permission

This commit is contained in:
Alexis Loskoutoff committed 2026-10-13 19:32:53 +02:00
1 parent 6acf346262
commit f1bd157438
1 file changed
+44
+44
View File
@@ -48,6 +48,50 @@ describe('Certificates endpoints', () => {
});
});
it('User with certificates view permission cannot validate custom certificate', () => {
const viewer = {
email: 'viewer@example.com',
secret: 'changeme',
};
cy.task('backendApiPost', {
token: token,
path: '/api/users',
data: {
name: 'Certificate Viewer',
nickname: 'Viewer',
email: viewer.email,
roles: ['user'],
auth: {
type: 'password',
secret: viewer.secret,
},
},
}).then((user) => {
cy.task('backendApiPut', {
token: token,
path: `/api/users/${user.id}/permissions`,
data: {
certificates: 'view',
},
});
cy.getToken(null, {identity: viewer.email, secret: viewer.secret}).then((viewerToken) => {
cy.task('backendApiPostFiles', {
token: viewerToken,
path: '/api/nginx/certificates/validate',
files: {
certificate: certFile,
certificate_key: keyFile,
},
returnOnError: true,
}).then((data) => {
expect(data.error.code).to.equal(403);
});
});
});
});
it('Custom certificate lifecycle', () => {
// Create custom cert
cy.task('backendApiPost', {