Skip to content

Commit

Permalink
Add cleanup abilities e2e tests (#2740)
Browse files Browse the repository at this point in the history
* Add host cleanup abilities test in host details view

* Add host cleanup authorization test in overview

* Add app instance authorization test in sap details view

* Add app instance cleanup authorization test in systems overview

* Add database instance cleanup authorization tests in databases view
  • Loading branch information
arbulu89 authored Jul 4, 2024
1 parent b962efc commit 2423563
Show file tree
Hide file tree
Showing 5 changed files with 231 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/e2e/cypress/e2e/databases_overview.cy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { createUserRequestFactory } from '@lib/test-utils/factories';

context('Databases Overview', () => {
before(() => {
cy.loadScenario('healthy-27-node-SAP-cluster');
Expand Down Expand Up @@ -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');
});
});
});
});
24 changes: 24 additions & 0 deletions test/e2e/cypress/e2e/host_details.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
});
});
40 changes: 40 additions & 0 deletions test/e2e/cypress/e2e/hosts_overview.cy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { createUserRequestFactory } from '@lib/test-utils/factories';

import {
availableHosts,
agents,
Expand Down Expand Up @@ -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');
});
});
});
});
44 changes: 44 additions & 0 deletions test/e2e/cypress/e2e/sap_system_details.cy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { createUserRequestFactory } from '@lib/test-utils/factories';

import {
selectedSystem,
attachedHosts,
Expand Down Expand Up @@ -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');
});
});
});
});
78 changes: 78 additions & 0 deletions test/e2e/cypress/e2e/sap_systems_overview.cy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { createUserRequestFactory } from '@lib/test-utils/factories';

import {
availableSAPSystems,
isHanaInstace,
Expand Down Expand Up @@ -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');
});
});
});
});

0 comments on commit 2423563

Please sign in to comment.