diff --git a/test/e2e/cypress/e2e/databases_overview.cy.js b/test/e2e/cypress/e2e/databases_overview.cy.js index c279ffc146..1555bf8a47 100644 --- a/test/e2e/cypress/e2e/databases_overview.cy.js +++ b/test/e2e/cypress/e2e/databases_overview.cy.js @@ -1,3 +1,5 @@ +import { createUserRequestFactory } from '@lib/test-utils/factories'; + context('Databases Overview', () => { before(() => { cy.loadScenario('healthy-27-node-SAP-cluster'); @@ -128,4 +130,47 @@ context('Databases Overview', () => { cy.contains(hddDatabase.sid).should('not.exist'); }); }); + + describe('Forbidden actions', () => { + const password = 'password'; + + beforeEach(() => { + cy.deleteAllUsers(); + cy.logout(); + const user = createUserRequestFactory.build({ + password, + password_confirmation: password, + }); + cy.wrap(user).as('user'); + }); + + describe('Database instance clean up', () => { + before(() => { + cy.loadScenario('sap-systems-overview-HDD-10-present'); + cy.loadScenario('sap-systems-overview-HDD-10-absent'); + }); + + it('should forbid database instance cleanup', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, []); + cy.login(user.username, password); + }); + cy.visit('/databases'); + + cy.contains('button', 'Clean up').should('be.disabled'); + }); + + it('should allow database instance clean up', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, [ + { name: 'cleanup', resource: 'database_instance' }, + ]); + cy.login(user.username, password); + }); + cy.visit('/databases'); + + cy.contains('button', 'Clean up').should('be.enabled'); + }); + }); + }); }); diff --git a/test/e2e/cypress/e2e/host_details.cy.js b/test/e2e/cypress/e2e/host_details.cy.js index c3610d847d..262d58d01e 100644 --- a/test/e2e/cypress/e2e/host_details.cy.js +++ b/test/e2e/cypress/e2e/host_details.cy.js @@ -514,5 +514,29 @@ context('Host Details', () => { cy.contains('button', 'Save Checks Selection').should('be.enabled'); }); }); + + describe('Clean up', () => { + it('should forbid host clean up', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, []); + cy.login(user.username, password); + }); + cy.visit(`/hosts/${selectedHost.agentId}`); + + cy.contains('button', 'Clean up').should('be.disabled'); + }); + + it('should allow host clean up', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, [ + { name: 'cleanup', resource: 'host' }, + ]); + cy.login(user.username, password); + }); + cy.visit(`/hosts/${selectedHost.agentId}`); + + cy.contains('button', 'Clean up').should('be.enabled'); + }); + }); }); }); diff --git a/test/e2e/cypress/e2e/hosts_overview.cy.js b/test/e2e/cypress/e2e/hosts_overview.cy.js index 0281e875e0..5d8749d9ae 100644 --- a/test/e2e/cypress/e2e/hosts_overview.cy.js +++ b/test/e2e/cypress/e2e/hosts_overview.cy.js @@ -1,3 +1,5 @@ +import { createUserRequestFactory } from '@lib/test-utils/factories'; + import { availableHosts, agents, @@ -335,4 +337,42 @@ context('Hosts Overview', () => { }); }); }); + + describe('Forbidden actions', () => { + const password = 'password'; + + beforeEach(() => { + cy.deleteAllUsers(); + cy.logout(); + const user = createUserRequestFactory.build({ + password, + password_confirmation: password, + }); + cy.wrap(user).as('user'); + }); + + describe('Clean up', () => { + it('should forbid host clean up', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, []); + cy.login(user.username, password); + }); + cy.visit(`/hosts`); + + cy.contains('button', 'Clean up').should('be.disabled'); + }); + + it('should allow host clean up', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, [ + { name: 'cleanup', resource: 'host' }, + ]); + cy.login(user.username, password); + }); + cy.visit(`/hosts`); + + cy.contains('button', 'Clean up').should('be.enabled'); + }); + }); + }); }); diff --git a/test/e2e/cypress/e2e/sap_system_details.cy.js b/test/e2e/cypress/e2e/sap_system_details.cy.js index 4b7f3a9672..d8a8858881 100644 --- a/test/e2e/cypress/e2e/sap_system_details.cy.js +++ b/test/e2e/cypress/e2e/sap_system_details.cy.js @@ -1,3 +1,5 @@ +import { createUserRequestFactory } from '@lib/test-utils/factories'; + import { selectedSystem, attachedHosts, @@ -153,4 +155,46 @@ context('SAP system details', () => { cy.contains(hostToDeregister.features).should('exist'); }); }); + + describe('Forbidden actions', () => { + const password = 'password'; + + beforeEach(() => { + cy.deleteAllUsers(); + cy.logout(); + const user = createUserRequestFactory.build({ + password, + password_confirmation: password, + }); + cy.wrap(user).as('user'); + }); + + describe('Application instance clean up', () => { + before(() => { + cy.loadScenario(`sap-systems-overview-NWD-00-absent`); + }); + + it('should forbid application instance cleanup', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, []); + cy.login(user.username, password); + }); + cy.visit(`/sap_systems/${selectedSystem.Id}`); + + cy.contains('button', 'Clean up').should('be.disabled'); + }); + + it('should allow application instance clenaup', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, [ + { name: 'cleanup', resource: 'application_instance' }, + ]); + cy.login(user.username, password); + }); + cy.visit(`/sap_systems/${selectedSystem.Id}`); + + cy.contains('button', 'Clean up').should('be.enabled'); + }); + }); + }); }); diff --git a/test/e2e/cypress/e2e/sap_systems_overview.cy.js b/test/e2e/cypress/e2e/sap_systems_overview.cy.js index 6194c3d63e..87ad70dab7 100644 --- a/test/e2e/cypress/e2e/sap_systems_overview.cy.js +++ b/test/e2e/cypress/e2e/sap_systems_overview.cy.js @@ -1,3 +1,5 @@ +import { createUserRequestFactory } from '@lib/test-utils/factories'; + import { availableSAPSystems, isHanaInstace, @@ -502,4 +504,80 @@ context('SAP Systems Overview', () => { cy.contains(nwdSystem.sid).should('not.exist'); }); }); + + describe('Forbidden actions', () => { + const password = 'password'; + + before(() => { + cy.loadScenario('sapsystem-NWD-restore'); + }); + + beforeEach(() => { + cy.deleteAllUsers(); + cy.logout(); + const user = createUserRequestFactory.build({ + password, + password_confirmation: password, + }); + cy.wrap(user).as('user'); + }); + + describe('Application instance clean up', () => { + before(() => { + cy.loadScenario('sap-systems-overview-NWD-00-absent'); + cy.loadScenario('sap-systems-overview-HDD-10-present'); + }); + + it('should forbid application instance cleanup', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, []); + cy.login(user.username, password); + }); + cy.visit('/sap_systems'); + + cy.contains('button', 'Clean up').should('be.disabled'); + }); + + it('should allow application instance clenaup', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, [ + { name: 'cleanup', resource: 'application_instance' }, + ]); + cy.login(user.username, password); + }); + cy.visit('/sap_systems'); + + cy.contains('button', 'Clean up').should('be.enabled'); + }); + }); + + describe('Database instance clean up', () => { + before(() => { + cy.loadScenario('sap-systems-overview-NWD-00-present'); + cy.loadScenario('sap-systems-overview-HDD-10-absent'); + }); + + it('should forbid database instance cleanup', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, []); + cy.login(user.username, password); + }); + cy.visit('/sap_systems'); + + cy.contains('button', 'Clean up').should('be.disabled'); + }); + + it('should allow database instance clean up', () => { + cy.get('@user').then((user) => { + cy.createUserWithAbilities(user, [ + { name: 'cleanup', resource: 'database_instance' }, + ]); + cy.login(user.username, password); + }); + cy.visit('/sap_systems'); + + cy.contains('button', 'Clean up').should('be.enabled'); + }); + }); + }); });