From d1668d282bbfe75b7f0353789f20b79ca009dff5 Mon Sep 17 00:00:00 2001 From: Rastislav Krutak <492918@mail.muni.cz> Date: Wed, 9 Aug 2023 08:19:30 +0200 Subject: [PATCH 01/22] test(admin): e2e tests for blocked logins Added e2e tests for blocked logins page. --- .../src/e2e/admin/perun-admin.cy.js | 57 +++++++++++++++++++ .../src/e2e/admin/perun-observer.cy.js | 10 ++++ .../admin-blocked-logins.component.html | 2 + .../block-logins-dialog.component.html | 2 + .../unblock-logins-dialog.component.html | 7 ++- ...blocked-logins-dynamic-list.component.html | 9 +-- 6 files changed, 82 insertions(+), 5 deletions(-) diff --git a/apps/admin-gui-e2e/src/e2e/admin/perun-admin.cy.js b/apps/admin-gui-e2e/src/e2e/admin/perun-admin.cy.js index a12cb6eee..41f39ed37 100644 --- a/apps/admin-gui-e2e/src/e2e/admin/perun-admin.cy.js +++ b/apps/admin-gui-e2e/src/e2e/admin/perun-admin.cy.js @@ -7,6 +7,9 @@ describe('Perun admin management with role Perun admin', () => { const dbExtSourceName = 'test_ext_source_db'; const dbConsentHubName = 'test-e2e-facility-from-db-3'; const dbOwnerName = 'DbOwnerTest'; + const loginToBlock = "testLoginToBlock" + const dbBlockedLogin = "test_blocking_login" + const dbBlockedLoginListOnly = "test_blocking_login_list" const dbSearcherAttrDisplayName = 'login-namespace:einfra'; const dbSearcherAttrValue = 'e2etestlogin'; @@ -199,6 +202,60 @@ describe('Perun admin management with role Perun admin', () => { }); }); + context('Blocked logins management', () => { + beforeEach(() => { + cy.get('[data-cy=blocked-logins]') + .click(); + }); + + it("test get blocked login", () => { + cy.get('[data-cy=filter-input]') + .type(dbBlockedLoginListOnly, {force: true}) + .get(`[data-cy=${dbBlockedLoginListOnly}-checkbox]`) + .should('exist'); + }) + + it('test block login', () => { + cy.intercept('**/usersManager/blockLogins**') + .as('blockLogin') + .intercept('**/usersManager/getBlockedLoginsPage**') + .as('getBlockedLogins') + .get('[data-cy=block-logins-button]') + .click({force: true}) + .get('[data-cy=logins-input]') + .type(loginToBlock, {force: true}) + .get('[data-cy=submit-blocked-logins-button]') + .click() + .wait('@blockLogin') + .wait('@getBlockedLogins') + // assert that the login is listed as blocked + .get('[data-cy=filter-input]') + .type(loginToBlock, {force: true}) + .get(`[data-cy=${loginToBlock}-checkbox]`) + .should('exist'); + }); + + it('test unblock login', () => { + cy.intercept('**/usersManager/unblockLoginsById**') + .as('unblockLogins') + .intercept('**/usersManager/getBlockedLoginsPage**') + .as('getBlockedLogins') + .get('[data-cy=filter-input]') + .type(dbBlockedLogin, {force: true}) + .get(`[data-cy=${dbBlockedLogin}-checkbox]`) + .click() + .get('[data-cy=unblock-logins-button]') + .click({force: true}) + .get('[data-cy=unblock-button-dialog]') + .click() + .wait('@unblockLogins') + .wait('@getBlockedLogins') + // assert that the login is no longer listed as blocked + .get(`[data-cy=${dbBlockedLogin}-checkbox]`) + .should('not.exist'); + }); + }); + it('test list ext sources', () => { cy.get('[data-cy=external-sources]') .click() diff --git a/apps/admin-gui-e2e/src/e2e/admin/perun-observer.cy.js b/apps/admin-gui-e2e/src/e2e/admin/perun-observer.cy.js index 869932c5a..5e1d8040b 100644 --- a/apps/admin-gui-e2e/src/e2e/admin/perun-observer.cy.js +++ b/apps/admin-gui-e2e/src/e2e/admin/perun-observer.cy.js @@ -11,6 +11,7 @@ describe('Perun admin management with role Perun observer', () => { const dbSearcherAttrValue = 'e2etestlogin'; const dbSearcherUserFirstName = 'Test6'; const dbOwnerName = 'DbOwnerTest'; + const dbBlockedLoginListOnly = "test_blocking_login_list" before(() => { cy.login('PERUN_OBSERVER', 'perunObserver'); @@ -114,4 +115,13 @@ describe('Perun admin management with role Perun observer', () => { .get(`[data-cy=${dbSearcherUserFirstName.toLowerCase()}-firstName-td]`) .should('exist'); }); + + it("test get blocked login", () => { + cy.get('[data-cy=blocked-logins]') + .click() + .get('[data-cy=filter-input]') + .type(dbBlockedLoginListOnly, {force: true}) + .get(`[data-cy=${dbBlockedLoginListOnly}-checkbox]`) + .should('exist'); + }); }); diff --git a/apps/admin-gui/src/app/admin/pages/admin-page/admin-blocked-logins/admin-blocked-logins.component.html b/apps/admin-gui/src/app/admin/pages/admin-page/admin-blocked-logins/admin-blocked-logins.component.html index 0cecf5c3a..95d4ca732 100644 --- a/apps/admin-gui/src/app/admin/pages/admin-page/admin-blocked-logins/admin-blocked-logins.component.html +++ b/apps/admin-gui/src/app/admin/pages/admin-page/admin-blocked-logins/admin-blocked-logins.component.html @@ -7,6 +7,7 @@