Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check execution policy e2e tests #2742

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 });
arbulu89 marked this conversation as resolved.
Show resolved Hide resolved

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`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we could have cy.contains('button', 'Start Execution').should('be.enabled');


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 });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mouseover ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not work because the button is disabled :/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe just better to check that the button is disabled?
We already test the tooltip in the unit tests

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the button is disabled because the checks are not selected, and wanda is not integrated and all the steps are missing, so I simply check that the tooltip it's not present, so it's disabled but not because of the policy, it's a little bit weird but rn it's what we have


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`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add Here we could have cy.contains('button', 'Start Execution').should('be.enabled');


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.