From 05bcb43b88c91dc3ef9980801c4acac6c5ff943d Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Wed, 3 Jul 2024 15:57:37 +0200 Subject: [PATCH] Check execution policy e2e tests --- .../cypress/e2e/hana_cluster_details.cy.js | 38 +++++++++++++++++++ test/e2e/cypress/e2e/host_details.cy.js | 37 ++++++++++++++++++ test/e2e/package-lock.json | 4 +- 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/test/e2e/cypress/e2e/hana_cluster_details.cy.js b/test/e2e/cypress/e2e/hana_cluster_details.cy.js index 04be920f7f..be719253f0 100644 --- a/test/e2e/cypress/e2e/hana_cluster_details.cy.js +++ b/test/e2e/cypress/e2e/hana_cluster_details.cy.js @@ -342,6 +342,44 @@ context('HANA cluster details', () => { cy.wrap(user).as('user'); }); + describe('Check Execution', () => { + it('should forbid check execution when the correct user abilities are missing', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, []); + cy.login(user.username, password); + }); + + cy.visit(`/clusters/${availableHanaCluster.id}/settings`); + + cy.contains('button', 'Start Execution').should('be.disabled'); + + cy.contains('button', 'Start Execution').click({ force: true }); + + cy.contains('span', 'You are not authorized for this action').should( + 'be.visible' + ); + }); + + it('should enable check execution button when the correct user abilities are present', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, [ + { name: 'all', resource: 'cluster_checks_execution' }, + ]); + cy.login(user.username, password); + }); + + cy.visit(`/clusters/${availableHanaCluster.id}/settings`); + + cy.contains('button', 'Start Execution').trigger('mouseover', { + force: true, + }); + + cy.contains('span', 'You are not authorized for this action').should( + 'not.exist' + ); + }); + }); + describe('Check Selection', () => { it('should forbid check selection saving', () => { cy.get('@user').then((user) => { diff --git a/test/e2e/cypress/e2e/host_details.cy.js b/test/e2e/cypress/e2e/host_details.cy.js index c3610d847d..063a167a2f 100644 --- a/test/e2e/cypress/e2e/host_details.cy.js +++ b/test/e2e/cypress/e2e/host_details.cy.js @@ -491,6 +491,43 @@ context('Host Details', () => { cy.wrap(user).as('user'); }); + describe('Check Execution', () => { + it('should forbid check execution when the correct user abilities are not present', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, []); + cy.login(user.username, password); + }); + cy.visit(`/hosts/${selectedHost.agentId}/settings`); + + cy.contains('button', 'Start Execution').should('be.disabled'); + + cy.contains('button', 'Start Execution').click({ force: true }); + + cy.contains('span', 'You are not authorized for this action').should( + 'be.visible' + ); + }); + + it('should enable check execution button when the correct user abilities are present', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, [ + { name: 'all', resource: 'host_checks_execution' }, + ]); + cy.login(user.username, password); + }); + + cy.visit(`/hosts/${selectedHost.agentId}/settings`); + + cy.contains('button', 'Start Execution').trigger('mouseover', { + force: true, + }); + + cy.contains('span', 'You are not authorized for this action').should( + 'not.exist' + ); + }); + }); + describe('Check Selection', () => { it('should forbid check selection saving', () => { cy.get('@user').then((user) => { diff --git a/test/e2e/package-lock.json b/test/e2e/package-lock.json index fff9a447a8..24ca2049a2 100644 --- a/test/e2e/package-lock.json +++ b/test/e2e/package-lock.json @@ -1,12 +1,12 @@ { "name": "trento-e2e-tests", - "version": "2.3.0", + "version": "2.3.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "trento-e2e-tests", - "version": "2.3.0", + "version": "2.3.1", "dependencies": { "@cypress/webpack-preprocessor": "^5.16.1", "date-fns": "^3.3.1",