Skip to content

Commit

Permalink
Check execution policy e2e tests (#2742)
Browse files Browse the repository at this point in the history
* Check execution policy e2e tests

* Add e2e check execution buttons in details for host and cluster
  • Loading branch information
CDimonaco authored Jul 4, 2024
1 parent a7980e0 commit c383516
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 2 deletions.
48 changes: 48 additions & 0 deletions test/e2e/cypress/e2e/hana_cluster_details.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,54 @@ context('HANA cluster details', () => {
cy.wrap(user).as('user');
});

describe('Check Execution', () => {
it('should forbid check execution when the correct user abilities are missing in details and settings', () => {
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'
);

cy.visit(`/clusters/${availableHanaCluster.id}`);

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) => {
Expand Down
46 changes: 46 additions & 0 deletions test/e2e/cypress/e2e/host_details.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,52 @@ context('Host Details', () => {
cy.wrap(user).as('user');
});

describe('Check Execution', () => {
it('should forbid check execution when the correct user abilities are not present in both settings and details', () => {
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'
);
cy.visit(`/hosts/${selectedHost.agentId}`);

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) => {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c383516

Please sign in to comment.