From ab57fb32b4ec8e0c41aeb940b276516abcf2e84f Mon Sep 17 00:00:00 2001 From: leanneeliatra <131779422+leanneeliatra@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:26:57 +0100 Subject: [PATCH] When a user has no roles, logout on button click (#830) * adding test to check when a user has no roles, clicking button will log them out Signed-off-by: leanneeliatra Signed-off-by: leanne.laceybyrne@eliatra.com * Remove unneeded code & depreciated server() Signed-off-by: leanneeliatra Signed-off-by: leanne.laceybyrne@eliatra.com * remove extra comments Signed-off-by: leanneeliatra Signed-off-by: leanne.laceybyrne@eliatra.com * removed whitespace Signed-off-by: leanne.laceybyrne@eliatra.com * Update missing_role_button_logout.js updating as per updates & request Signed-off-by: leanneeliatra <131779422+leanneeliatra@users.noreply.github.com> * Update cypress/integration/plugins/security-dashboards-plugin/missing_role_button_logout.js Co-authored-by: Yulong Ruan Signed-off-by: leanneeliatra <131779422+leanneeliatra@users.noreply.github.com> * Update missing_role_button_logout.js Signed-off-by: leanneeliatra <131779422+leanneeliatra@users.noreply.github.com> * Update missing_role_button_logout.js Signed-off-by: leanneeliatra <131779422+leanneeliatra@users.noreply.github.com> * Update missing_role_button_logout.js Signed-off-by: leanneeliatra <131779422+leanneeliatra@users.noreply.github.com> --------- Signed-off-by: leanneeliatra Signed-off-by: leanne.laceybyrne@eliatra.com Signed-off-by: leanneeliatra <131779422+leanneeliatra@users.noreply.github.com> Co-authored-by: Yulong Ruan --- .../missing_role_button_logout.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 cypress/integration/plugins/security-dashboards-plugin/missing_role_button_logout.js diff --git a/cypress/integration/plugins/security-dashboards-plugin/missing_role_button_logout.js b/cypress/integration/plugins/security-dashboards-plugin/missing_role_button_logout.js new file mode 100644 index 000000000..5a575bd8a --- /dev/null +++ b/cypress/integration/plugins/security-dashboards-plugin/missing_role_button_logout.js @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ +if (Cypress.env('SECURITY_ENABLED')) { + it('Tests if no role button redirects to logout screen', () => { + cy.visit('/app/customerror/missing-role'); + + cy.contains('button', 'Logout').should('be.visible').click(); + + cy.intercept({ + method: 'POST', + url: '/auth/logout', + }); + + cy.getElementByTestId('submit').should('contain.text', 'Log in'); + }); +}