Skip to content

Commit

Permalink
Check execution policy e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CDimonaco committed Jul 4, 2024
1 parent b962efc commit 05bcb43
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 2 deletions.
38 changes: 38 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,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) => {
Expand Down
37 changes: 37 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,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) => {
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 05bcb43

Please sign in to comment.