From 61463477141606bc445c8db270b8229195b1525b Mon Sep 17 00:00:00 2001 From: Fede Alonso Date: Wed, 13 Nov 2024 11:46:28 +0100 Subject: [PATCH 1/6] fix: Contributor role user --- .../cypress/cypress/support/commands/application.ts | 4 ++-- .../cypress/cypress/tests/e2e/application.cy.ts | 4 ++-- .../clusterSettings/testAdminClusterSettings.cy.ts | 5 +++-- .../tests/e2e/storageClasses/clusterStorage.cy.ts | 6 +++--- frontend/src/__tests__/cypress/cypress/types.ts | 2 +- .../src/__tests__/cypress/cypress/utils/e2eUsers.ts | 2 +- .../src/__tests__/cypress/cypress/utils/testConfig.ts | 10 +++++----- .../src/__tests__/cypress/test-variables.yml.example | 4 ++++ 8 files changed, 21 insertions(+), 16 deletions(-) diff --git a/frontend/src/__tests__/cypress/cypress/support/commands/application.ts b/frontend/src/__tests__/cypress/cypress/support/commands/application.ts index 7c5a8f106d..e3d6dd2c75 100644 --- a/frontend/src/__tests__/cypress/cypress/support/commands/application.ts +++ b/frontend/src/__tests__/cypress/cypress/support/commands/application.ts @@ -1,7 +1,7 @@ import type { MatcherOptions } from '@testing-library/cypress'; import type { Matcher, MatcherOptions as DTLMatcherOptions } from '@testing-library/dom'; import type { UserAuthConfig, DashboardConfig } from '~/__tests__/cypress/cypress/types'; -import { TEST_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { CONTRIBUTOR_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; import { getDashboardConfig, getNotebookControllerConfig, @@ -148,7 +148,7 @@ declare global { } } -Cypress.Commands.add('visitWithLogin', (url, user = TEST_USER) => { +Cypress.Commands.add('visitWithLogin', (url, user = CONTRIBUTOR_USER) => { if (Cypress.env('MOCK')) { cy.visit(url); } else { diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/application.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/application.cy.ts index 5639858ff5..d9df42091b 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/application.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/application.cy.ts @@ -1,8 +1,8 @@ -import { TEST_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { CONTRIBUTOR_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; describe('application', { testIsolation: false }, () => { it('should login and load page', () => { cy.visitWithLogin('/'); - cy.findByRole('banner', { name: 'page masthead' }).contains(TEST_USER.USERNAME); + cy.findByRole('banner', { name: 'page masthead' }).contains(CONTRIBUTOR_USER.USERNAME); }); }); diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testAdminClusterSettings.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testAdminClusterSettings.cy.ts index 293e48c539..fafc6e8487 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testAdminClusterSettings.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testAdminClusterSettings.cy.ts @@ -1,4 +1,4 @@ -import { ADMIN_USER, TEST_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { ADMIN_USER, CONTRIBUTOR_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; import { clusterSettings } from '~/__tests__/cypress/cypress/pages/clusterSettings'; import { pageNotfound } from '~/__tests__/cypress/cypress/pages/pageNotFound'; import type { DashboardConfig, NotebookControllerConfig } from '~/__tests__/cypress/cypress/types'; @@ -8,6 +8,7 @@ import { validateStopIdleNotebooks, validateNotebookPodTolerations, } from '~/__tests__/cypress/cypress/utils/clusterSettingsUtils'; +import cypress from 'cypress'; describe('Verify that only the Cluster Admin can access Cluster Settings', () => { let dashboardConfig: DashboardConfig; @@ -52,7 +53,7 @@ describe('Verify that only the Cluster Admin can access Cluster Settings', () => }); it('Test User - should not have access rights to view the Cluster Settings tab', () => { cy.step('Log into the application'); - cy.visitWithLogin('/', TEST_USER); + cy.visitWithLogin('/', CONTRIBUTOR_USER); cy.step('Navigate to the Cluster Settings'); clusterSettings.visit(false); diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/storageClasses/clusterStorage.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/storageClasses/clusterStorage.cy.ts index 383f341683..0faf968e0c 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/storageClasses/clusterStorage.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/storageClasses/clusterStorage.cy.ts @@ -1,4 +1,4 @@ -import { TEST_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { CONTRIBUTOR_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; import { provisionClusterStorageSCFeature, tearDownClusterStorageSCFeature, @@ -12,7 +12,7 @@ const dspName = 'qe-cluster-storage-sc-dsp'; describe('Regular Users can make use of the Storage Classes in the Cluster Storage tab from DSP ', () => { before(() => { - provisionClusterStorageSCFeature(dspName, TEST_USER.USERNAME); + provisionClusterStorageSCFeature(dspName, CONTRIBUTOR_USER.USERNAME); }); after(() => { @@ -20,7 +20,7 @@ describe('Regular Users can make use of the Storage Classes in the Cluster Stora }); it('If all SC are disabled except one, the SC dropdown should be disabled', () => { - cy.visitWithLogin('/projects', TEST_USER); + cy.visitWithLogin('/projects', CONTRIBUTOR_USER); // Open the project projectListPage.filterProjectByName(dspName); projectListPage.findProjectLink(dspName).click(); diff --git a/frontend/src/__tests__/cypress/cypress/types.ts b/frontend/src/__tests__/cypress/cypress/types.ts index 7fbd56738b..083e63d1ac 100644 --- a/frontend/src/__tests__/cypress/cypress/types.ts +++ b/frontend/src/__tests__/cypress/cypress/types.ts @@ -81,7 +81,7 @@ export type CommandLineResult = { export type TestConfig = { ODH_DASHBOARD_URL: string; - TEST_USER: UserAuthConfig; + TEST_USER_3: UserAuthConfig; OCP_ADMIN_USER: UserAuthConfig; S3: AWSS3Buckets; }; diff --git a/frontend/src/__tests__/cypress/cypress/utils/e2eUsers.ts b/frontend/src/__tests__/cypress/cypress/utils/e2eUsers.ts index cad0486def..2c8e2f4720 100644 --- a/frontend/src/__tests__/cypress/cypress/utils/e2eUsers.ts +++ b/frontend/src/__tests__/cypress/cypress/utils/e2eUsers.ts @@ -1,4 +1,4 @@ import type { UserAuthConfig } from '~/__tests__/cypress/cypress/types'; -export const TEST_USER: UserAuthConfig = Cypress.env('TEST_USER'); +export const CONTRIBUTOR_USER: UserAuthConfig = Cypress.env('CONTRIBUTOR_USER'); export const ADMIN_USER: UserAuthConfig = Cypress.env('ADMIN_USER'); diff --git a/frontend/src/__tests__/cypress/cypress/utils/testConfig.ts b/frontend/src/__tests__/cypress/cypress/utils/testConfig.ts index 4efb321c05..fd41e8b047 100644 --- a/frontend/src/__tests__/cypress/cypress/utils/testConfig.ts +++ b/frontend/src/__tests__/cypress/cypress/utils/testConfig.ts @@ -27,10 +27,10 @@ const testConfig: TestConfig | undefined = env.CY_TEST_CONFIG export const BASE_URL = testConfig?.ODH_DASHBOARD_URL || env.BASE_URL || ''; -const TEST_USER: UserAuthConfig = testConfig?.TEST_USER ?? { - AUTH_TYPE: env.TEST_USER_AUTH_TYPE || '', - USERNAME: env.TEST_USER_USERNAME || '', - PASSWORD: env.TEST_USER_PASSWORD || '', +const CONTRIBUTOR_USER: UserAuthConfig = testConfig?.TEST_USER_3 ?? { + AUTH_TYPE: env.TEST_USER_3_AUTH_TYPE || '', + USERNAME: env.TEST_USER_3_USERNAME || '', + PASSWORD: env.TEST_USER_3_PASSWORD || '', }; const ADMIN_USER: UserAuthConfig = testConfig?.OCP_ADMIN_USER ?? { @@ -54,7 +54,7 @@ const AWS_PIPELINES: AWSS3Buckets = { // spread the cypressEnv variables into the cypress config export const cypressEnv = { - TEST_USER, + CONTRIBUTOR_USER, ADMIN_USER, AWS_PIPELINES, }; diff --git a/frontend/src/__tests__/cypress/test-variables.yml.example b/frontend/src/__tests__/cypress/test-variables.yml.example index 0cad9a7ed0..ea157e30e7 100644 --- a/frontend/src/__tests__/cypress/test-variables.yml.example +++ b/frontend/src/__tests__/cypress/test-variables.yml.example @@ -3,6 +3,10 @@ TEST_USER: AUTH_TYPE: foo-auth USERNAME: foo-user PASSWORD: foo-passwd +TEST_USER_3: + AUTH_TYPE: contributor-auth + USERNAME: contributor-username + PASSWORD: contributor-passwd OCP_ADMIN_USER: AUTH_TYPE: adm-auth USERNAME: adminuser From 9dd5613ced9624eaa98ce89402477dbf2a2ab5dd Mon Sep 17 00:00:00 2001 From: Fede Alonso Date: Wed, 13 Nov 2024 12:06:45 +0100 Subject: [PATCH 2/6] delete unused import --- .../e2e/settings/clusterSettings/testAdminClusterSettings.cy.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testAdminClusterSettings.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testAdminClusterSettings.cy.ts index fafc6e8487..143d31a2ed 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testAdminClusterSettings.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testAdminClusterSettings.cy.ts @@ -8,7 +8,6 @@ import { validateStopIdleNotebooks, validateNotebookPodTolerations, } from '~/__tests__/cypress/cypress/utils/clusterSettingsUtils'; -import cypress from 'cypress'; describe('Verify that only the Cluster Admin can access Cluster Settings', () => { let dashboardConfig: DashboardConfig; From 509d4ce5bc0e41b80d12501927a6533b17805de8 Mon Sep 17 00:00:00 2001 From: Fede Alonso Date: Wed, 13 Nov 2024 12:21:49 +0100 Subject: [PATCH 3/6] use ADMIN_USER by default --- .../__tests__/cypress/cypress/support/commands/application.ts | 4 ++-- .../src/__tests__/cypress/cypress/tests/e2e/application.cy.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/__tests__/cypress/cypress/support/commands/application.ts b/frontend/src/__tests__/cypress/cypress/support/commands/application.ts index e3d6dd2c75..2dfb39255c 100644 --- a/frontend/src/__tests__/cypress/cypress/support/commands/application.ts +++ b/frontend/src/__tests__/cypress/cypress/support/commands/application.ts @@ -1,7 +1,7 @@ import type { MatcherOptions } from '@testing-library/cypress'; import type { Matcher, MatcherOptions as DTLMatcherOptions } from '@testing-library/dom'; import type { UserAuthConfig, DashboardConfig } from '~/__tests__/cypress/cypress/types'; -import { CONTRIBUTOR_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; import { getDashboardConfig, getNotebookControllerConfig, @@ -148,7 +148,7 @@ declare global { } } -Cypress.Commands.add('visitWithLogin', (url, user = CONTRIBUTOR_USER) => { +Cypress.Commands.add('visitWithLogin', (url, user = ADMIN_USER) => { if (Cypress.env('MOCK')) { cy.visit(url); } else { diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/application.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/application.cy.ts index d9df42091b..c1572939cb 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/application.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/application.cy.ts @@ -1,8 +1,8 @@ -import { CONTRIBUTOR_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; describe('application', { testIsolation: false }, () => { it('should login and load page', () => { cy.visitWithLogin('/'); - cy.findByRole('banner', { name: 'page masthead' }).contains(CONTRIBUTOR_USER.USERNAME); + cy.findByRole('banner', { name: 'page masthead' }).contains(ADMIN_USER.USERNAME); }); }); From 498164e80896f458e9b029d87a341a52ddc1fddf Mon Sep 17 00:00:00 2001 From: Fede Alonso Date: Thu, 14 Nov 2024 07:44:33 +0100 Subject: [PATCH 4/6] descriptive user names, including idp --- .../cypress/cypress/tests/e2e/application.cy.ts | 6 ++++-- .../e2e/dataScienceProjects/testProjectCreation.cy.ts | 4 ++-- .../cypress/cypress/tests/e2e/pipelines/pipelines.cy.ts | 4 ++-- .../clusterSettings/testAdminClusterSettings.cy.ts | 9 ++++++--- .../tests/e2e/storageClasses/clusterStorage.cy.ts | 6 +++--- .../tests/e2e/storageClasses/storageClasses.cy.ts | 8 ++++---- frontend/src/__tests__/cypress/cypress/utils/e2eUsers.ts | 6 ++++-- .../src/__tests__/cypress/cypress/utils/testConfig.ts | 8 ++++---- 8 files changed, 29 insertions(+), 22 deletions(-) diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/application.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/application.cy.ts index c1572939cb..49786a8d3f 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/application.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/application.cy.ts @@ -1,8 +1,10 @@ -import { ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; describe('application', { testIsolation: false }, () => { it('should login and load page', () => { cy.visitWithLogin('/'); - cy.findByRole('banner', { name: 'page masthead' }).contains(ADMIN_USER.USERNAME); + cy.findByRole('banner', { name: 'page masthead' }).contains( + HTPASSWD_CLUSTER_ADMIN_USER.USERNAME, + ); }); }); diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectCreation.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectCreation.cy.ts index 42e0a08d53..b31416fb91 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectCreation.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectCreation.cy.ts @@ -1,5 +1,5 @@ import yaml from 'js-yaml'; -import { ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; import { projectListPage, createProjectModal, @@ -45,7 +45,7 @@ describe('Verify Data Science Project - Creation and Deletion', () => { it('Create and Delete a Data Science Project in RHOAI', () => { // Authentication and navigation cy.step('Log into the application'); - cy.visitWithLogin('/', ADMIN_USER); + cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER); projectListPage.navigate(); // Initiate project creation diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/pipelines/pipelines.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/pipelines/pipelines.cy.ts index 4b76b669eb..f554df571a 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/pipelines/pipelines.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/pipelines/pipelines.cy.ts @@ -1,5 +1,5 @@ import { deleteOpenShiftProject } from '~/__tests__/cypress/cypress/utils/oc_commands/project'; -import { ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; import { projectListPage, projectDetails } from '~/__tests__/cypress/cypress/pages/projects'; import { pipelineImportModal } from '~/__tests__/cypress/cypress/pages/pipelines/pipelineImportModal'; import { createRunPage } from '~/__tests__/cypress/cypress/pages/pipelines/createRunPage'; @@ -27,7 +27,7 @@ describe('An admin user can import and run a pipeline', { testIsolation: false } it('An admin User can Import and Run a Pipeline', () => { // Login as an admin - cy.visitWithLogin('/', ADMIN_USER); + cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER); /** * Import Pipeline by URL from Project Details view diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testAdminClusterSettings.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testAdminClusterSettings.cy.ts index 143d31a2ed..e67e82746f 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testAdminClusterSettings.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/settings/clusterSettings/testAdminClusterSettings.cy.ts @@ -1,4 +1,7 @@ -import { ADMIN_USER, CONTRIBUTOR_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { + HTPASSWD_CLUSTER_ADMIN_USER, + LDAP_CONTRIBUTOR_USER, +} from '~/__tests__/cypress/cypress/utils/e2eUsers'; import { clusterSettings } from '~/__tests__/cypress/cypress/pages/clusterSettings'; import { pageNotfound } from '~/__tests__/cypress/cypress/pages/pageNotFound'; import type { DashboardConfig, NotebookControllerConfig } from '~/__tests__/cypress/cypress/types'; @@ -29,7 +32,7 @@ describe('Verify that only the Cluster Admin can access Cluster Settings', () => it('Admin should access Cluster Settings and see UI fields matching OpenShift configurations', () => { // Authentication and navigation cy.step('Log into the application'); - cy.visitWithLogin('/', ADMIN_USER); + cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER); cy.step('Navigate to Cluster Settings'); clusterSettings.visit(); @@ -52,7 +55,7 @@ describe('Verify that only the Cluster Admin can access Cluster Settings', () => }); it('Test User - should not have access rights to view the Cluster Settings tab', () => { cy.step('Log into the application'); - cy.visitWithLogin('/', CONTRIBUTOR_USER); + cy.visitWithLogin('/', LDAP_CONTRIBUTOR_USER); cy.step('Navigate to the Cluster Settings'); clusterSettings.visit(false); diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/storageClasses/clusterStorage.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/storageClasses/clusterStorage.cy.ts index 0faf968e0c..c52cd21825 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/storageClasses/clusterStorage.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/storageClasses/clusterStorage.cy.ts @@ -1,4 +1,4 @@ -import { CONTRIBUTOR_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { LDAP_CONTRIBUTOR_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; import { provisionClusterStorageSCFeature, tearDownClusterStorageSCFeature, @@ -12,7 +12,7 @@ const dspName = 'qe-cluster-storage-sc-dsp'; describe('Regular Users can make use of the Storage Classes in the Cluster Storage tab from DSP ', () => { before(() => { - provisionClusterStorageSCFeature(dspName, CONTRIBUTOR_USER.USERNAME); + provisionClusterStorageSCFeature(dspName, LDAP_CONTRIBUTOR_USER.USERNAME); }); after(() => { @@ -20,7 +20,7 @@ describe('Regular Users can make use of the Storage Classes in the Cluster Stora }); it('If all SC are disabled except one, the SC dropdown should be disabled', () => { - cy.visitWithLogin('/projects', CONTRIBUTOR_USER); + cy.visitWithLogin('/projects', LDAP_CONTRIBUTOR_USER); // Open the project projectListPage.filterProjectByName(dspName); projectListPage.findProjectLink(dspName).click(); diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/storageClasses/storageClasses.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/storageClasses/storageClasses.cy.ts index 898d792c7a..f09a759a38 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/storageClasses/storageClasses.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/storageClasses/storageClasses.cy.ts @@ -1,4 +1,4 @@ -import { ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; import { verifyStorageClassConfig, provisionStorageClassFeature, @@ -26,7 +26,7 @@ describe('An admin user can manage Storage Classes from Settings -> Storage clas }); it('An admin user can enable a disabled Storage Class', () => { - cy.visitWithLogin('/', ADMIN_USER); + cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER); storageClassesPage.navigate(); const scDisabledName = `${scName}-disabled-non-default`; // SC row exist @@ -51,7 +51,7 @@ describe('An admin user can manage Storage Classes from Settings -> Storage clas }); it('An admin user can disable an enabled Storage Class', () => { - cy.visitWithLogin('/', ADMIN_USER); + cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER); storageClassesPage.navigate(); const scEnabledName = `${scName}-enabled-non-default`; // SC row exist @@ -76,7 +76,7 @@ describe('An admin user can manage Storage Classes from Settings -> Storage clas }); it('An admin user can set an enabled Storage Class as the default one', () => { - cy.visitWithLogin('/', ADMIN_USER); + cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER); storageClassesPage.navigate(); const scToDefaultName = `${scName}-enabled-to-default`; const scToDefaultRow = storageClassesTable.getRowByConfigName(scToDefaultName); diff --git a/frontend/src/__tests__/cypress/cypress/utils/e2eUsers.ts b/frontend/src/__tests__/cypress/cypress/utils/e2eUsers.ts index 2c8e2f4720..bbeee3235a 100644 --- a/frontend/src/__tests__/cypress/cypress/utils/e2eUsers.ts +++ b/frontend/src/__tests__/cypress/cypress/utils/e2eUsers.ts @@ -1,4 +1,6 @@ import type { UserAuthConfig } from '~/__tests__/cypress/cypress/types'; -export const CONTRIBUTOR_USER: UserAuthConfig = Cypress.env('CONTRIBUTOR_USER'); -export const ADMIN_USER: UserAuthConfig = Cypress.env('ADMIN_USER'); +export const LDAP_CONTRIBUTOR_USER: UserAuthConfig = Cypress.env('LDAP_CONTRIBUTOR_USER'); +export const HTPASSWD_CLUSTER_ADMIN_USER: UserAuthConfig = Cypress.env( + 'HTPASSWD_CLUSTER_ADMIN_USER', +); diff --git a/frontend/src/__tests__/cypress/cypress/utils/testConfig.ts b/frontend/src/__tests__/cypress/cypress/utils/testConfig.ts index fd41e8b047..d6dd1a6029 100644 --- a/frontend/src/__tests__/cypress/cypress/utils/testConfig.ts +++ b/frontend/src/__tests__/cypress/cypress/utils/testConfig.ts @@ -27,13 +27,13 @@ const testConfig: TestConfig | undefined = env.CY_TEST_CONFIG export const BASE_URL = testConfig?.ODH_DASHBOARD_URL || env.BASE_URL || ''; -const CONTRIBUTOR_USER: UserAuthConfig = testConfig?.TEST_USER_3 ?? { +const LDAP_CONTRIBUTOR_USER: UserAuthConfig = testConfig?.TEST_USER_3 ?? { AUTH_TYPE: env.TEST_USER_3_AUTH_TYPE || '', USERNAME: env.TEST_USER_3_USERNAME || '', PASSWORD: env.TEST_USER_3_PASSWORD || '', }; -const ADMIN_USER: UserAuthConfig = testConfig?.OCP_ADMIN_USER ?? { +const HTPASSWD_CLUSTER_ADMIN_USER: UserAuthConfig = testConfig?.OCP_ADMIN_USER ?? { AUTH_TYPE: env.ADMIN_USER_AUTH_TYPE || '', USERNAME: env.ADMIN_USER_USERNAME || '', PASSWORD: env.ADMIN_USER_PASSWORD || '', @@ -54,8 +54,8 @@ const AWS_PIPELINES: AWSS3Buckets = { // spread the cypressEnv variables into the cypress config export const cypressEnv = { - CONTRIBUTOR_USER, - ADMIN_USER, + LDAP_CONTRIBUTOR_USER, + HTPASSWD_CLUSTER_ADMIN_USER, AWS_PIPELINES, }; From 9ef7b6f2a9d367b43e0e983bea7fdc90b3c9778a Mon Sep 17 00:00:00 2001 From: Fede Alonso Date: Thu, 14 Nov 2024 07:48:20 +0100 Subject: [PATCH 5/6] descriptive user names, including idp 2 --- .../__tests__/cypress/cypress/support/commands/application.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/__tests__/cypress/cypress/support/commands/application.ts b/frontend/src/__tests__/cypress/cypress/support/commands/application.ts index 2dfb39255c..a1895d9e9d 100644 --- a/frontend/src/__tests__/cypress/cypress/support/commands/application.ts +++ b/frontend/src/__tests__/cypress/cypress/support/commands/application.ts @@ -1,7 +1,7 @@ import type { MatcherOptions } from '@testing-library/cypress'; import type { Matcher, MatcherOptions as DTLMatcherOptions } from '@testing-library/dom'; import type { UserAuthConfig, DashboardConfig } from '~/__tests__/cypress/cypress/types'; -import { ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; import { getDashboardConfig, getNotebookControllerConfig, @@ -148,7 +148,7 @@ declare global { } } -Cypress.Commands.add('visitWithLogin', (url, user = ADMIN_USER) => { +Cypress.Commands.add('visitWithLogin', (url, user = HTPASSWD_CLUSTER_ADMIN_USER) => { if (Cypress.env('MOCK')) { cy.visit(url); } else { From e643c893b6594ed7703f57df852a2a3dbb3f514c Mon Sep 17 00:00:00 2001 From: Fede Alonso Date: Thu, 14 Nov 2024 08:04:49 +0100 Subject: [PATCH 6/6] modify new tests --- .../testProjectAdminPermissions.cy.ts | 22 ++++++++++++------- .../testProjectContributorPermissions.cy.ts | 22 ++++++++++++------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectAdminPermissions.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectAdminPermissions.cy.ts index dc39216355..02e2af1708 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectAdminPermissions.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectAdminPermissions.cy.ts @@ -1,7 +1,10 @@ import type { DataScienceProjectData } from '~/__tests__/cypress/cypress/types'; import { projectDetails, projectListPage } from '~/__tests__/cypress/cypress/pages/projects'; import { permissions } from '~/__tests__/cypress/cypress/pages/permissions'; -import { ADMIN_USER, TEST_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { + HTPASSWD_CLUSTER_ADMIN_USER, + LDAP_CONTRIBUTOR_USER, +} from '~/__tests__/cypress/cypress/utils/e2eUsers'; import { loadFixture } from '~/__tests__/cypress/cypress/utils/dataLoader'; import { createCleanProject } from '~/__tests__/cypress/cypress/utils/projectChecker'; import { deleteOpenShiftProject } from '~/__tests__/cypress/cypress/utils/oc_commands/project'; @@ -37,7 +40,7 @@ describe('Verify that users can provide admin project permissions to non-admin u it('Verify that user can be added as an Admin for a Project', () => { // Authentication and navigation cy.step('Log into the application'); - cy.visitWithLogin('/', ADMIN_USER); + cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER); // Project navigation, add user and provide admin permissions cy.step( @@ -50,21 +53,24 @@ describe('Verify that users can provide admin project permissions to non-admin u cy.step('Assign admin user Project Permissions'); permissions.findAddUserButton().click(); - permissions.getUserTable().findAddInput().type(TEST_USER.USERNAME); + permissions.getUserTable().findAddInput().type(LDAP_CONTRIBUTOR_USER.USERNAME); permissions .getUserTable() - .selectPermission(TEST_USER.USERNAME, 'Admin Edit the project and manage user access'); + .selectPermission( + LDAP_CONTRIBUTOR_USER.USERNAME, + 'Admin Edit the project and manage user access', + ); cy.step( - `Save the user and validate that ${TEST_USER.USERNAME} has been saved with admin permissions`, + `Save the user and validate that ${LDAP_CONTRIBUTOR_USER.USERNAME} has been saved with admin permissions`, ); permissions.getUserTable().findSaveNewButton().should('exist').and('be.visible').click(); - cy.contains(TEST_USER.USERNAME).should('exist'); + cy.contains(LDAP_CONTRIBUTOR_USER.USERNAME).should('exist'); }); it('Verify that user can access the created project with Admin rights', () => { // Authentication and navigation - cy.step(`Log into the application with ${TEST_USER.USERNAME}`); - cy.visitWithLogin('/', TEST_USER); + cy.step(`Log into the application with ${LDAP_CONTRIBUTOR_USER.USERNAME}`); + cy.visitWithLogin('/', LDAP_CONTRIBUTOR_USER); // Project navigation and validate permissions tab is accessible cy.step('Verify that the user has access to the created project and can access Permissions'); diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectContributorPermissions.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectContributorPermissions.cy.ts index b195df0057..6a849e6b52 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectContributorPermissions.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectContributorPermissions.cy.ts @@ -2,7 +2,10 @@ import { deleteOpenShiftProject } from '~/__tests__/cypress/cypress/utils/oc_com import { projectDetails, projectListPage } from '~/__tests__/cypress/cypress/pages/projects'; import type { DataScienceProjectData } from '~/__tests__/cypress/cypress/types'; import { permissions } from '~/__tests__/cypress/cypress/pages/permissions'; -import { ADMIN_USER, TEST_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; +import { + HTPASSWD_CLUSTER_ADMIN_USER, + LDAP_CONTRIBUTOR_USER, +} from '~/__tests__/cypress/cypress/utils/e2eUsers'; import { loadFixture } from '~/__tests__/cypress/cypress/utils/dataLoader'; import { createCleanProject } from '~/__tests__/cypress/cypress/utils/projectChecker'; @@ -37,7 +40,7 @@ describe('Verify that users can provide contributor project permissions to non-a it('Verify that user can be added as a Contributor for a Project', () => { // Authentication and navigation cy.step('Log into the application'); - cy.visitWithLogin('/', ADMIN_USER); + cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER); // Project navigation, add user and provide contributor permissions cy.step( @@ -50,22 +53,25 @@ describe('Verify that users can provide contributor project permissions to non-a cy.step('Assign contributor user Project Permissions'); permissions.findAddUserButton().click(); - permissions.getUserTable().findAddInput().type(TEST_USER.USERNAME); + permissions.getUserTable().findAddInput().type(LDAP_CONTRIBUTOR_USER.USERNAME); cy.debug(); permissions .getUserTable() - .selectPermission(TEST_USER.USERNAME, 'Contributor View and edit the project components'); + .selectPermission( + LDAP_CONTRIBUTOR_USER.USERNAME, + 'Contributor View and edit the project components', + ); cy.step( - `Save the user and validate that ${TEST_USER.USERNAME} has been saved with Contributor permissions`, + `Save the user and validate that ${LDAP_CONTRIBUTOR_USER.USERNAME} has been saved with Contributor permissions`, ); permissions.getUserTable().findSaveNewButton().should('exist').and('be.visible').click(); - cy.contains(TEST_USER.USERNAME).should('exist'); + cy.contains(LDAP_CONTRIBUTOR_USER.USERNAME).should('exist'); }); it('Verify that user can access the created project as a Contributor', () => { // Authentication and navigation - cy.step(`Log into the application with ${TEST_USER.USERNAME}`); - cy.visitWithLogin('/', TEST_USER); + cy.step(`Log into the application with ${LDAP_CONTRIBUTOR_USER.USERNAME}`); + cy.visitWithLogin('/', LDAP_CONTRIBUTOR_USER); // Project navigation and validate permissions tab is accessible cy.step('Verify that the user has access to the created project but cannot access Permissions');