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

Enhance visit with login #3469

Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -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 { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers';
import {
getDashboardConfig,
getNotebookControllerConfig,
Expand Down Expand Up @@ -148,7 +148,7 @@ declare global {
}
}

Cypress.Commands.add('visitWithLogin', (url, user = TEST_USER) => {
Cypress.Commands.add('visitWithLogin', (url, user = HTPASSWD_CLUSTER_ADMIN_USER) => {
if (Cypress.env('MOCK')) {
cy.visit(url);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { TEST_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(TEST_USER.USERNAME);
cy.findByRole('banner', { name: 'page masthead' }).contains(
HTPASSWD_CLUSTER_ADMIN_USER.USERNAME,
);
});
});
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(
Expand All @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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(
Expand All @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
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 { clusterSettings } from '~/__tests__/cypress/cypress/pages/clusterSettings';
import { pageNotfound } from '~/__tests__/cypress/cypress/pages/pageNotFound';
import type { DashboardConfig, NotebookControllerConfig } from '~/__tests__/cypress/cypress/types';
Expand Down Expand Up @@ -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();
Expand All @@ -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('/', TEST_USER);
cy.visitWithLogin('/', LDAP_CONTRIBUTOR_USER);

cy.step('Navigate to the Cluster Settings');
clusterSettings.visit(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TEST_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers';
import { LDAP_CONTRIBUTOR_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers';
import {
provisionClusterStorageSCFeature,
tearDownClusterStorageSCFeature,
Expand All @@ -12,15 +12,15 @@ 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, LDAP_CONTRIBUTOR_USER.USERNAME);
});

after(() => {
tearDownClusterStorageSCFeature(dspName);
});

it('If all SC are disabled except one, the SC dropdown should be disabled', () => {
cy.visitWithLogin('/projects', TEST_USER);
cy.visitWithLogin('/projects', LDAP_CONTRIBUTOR_USER);
// Open the project
projectListPage.filterProjectByName(dspName);
projectListPage.findProjectLink(dspName).click();
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/__tests__/cypress/cypress/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/__tests__/cypress/cypress/utils/e2eUsers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type { UserAuthConfig } from '~/__tests__/cypress/cypress/types';

export const TEST_USER: UserAuthConfig = Cypress.env('TEST_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',
);
14 changes: 7 additions & 7 deletions frontend/src/__tests__/cypress/cypress/utils/testConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ 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 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 || '',
Expand All @@ -54,8 +54,8 @@ const AWS_PIPELINES: AWSS3Buckets = {

// spread the cypressEnv variables into the cypress config
export const cypressEnv = {
TEST_USER,
ADMIN_USER,
LDAP_CONTRIBUTOR_USER,
HTPASSWD_CLUSTER_ADMIN_USER,
AWS_PIPELINES,
};

Expand Down
4 changes: 4 additions & 0 deletions frontend/src/__tests__/cypress/test-variables.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ TEST_USER:
AUTH_TYPE: foo-auth
USERNAME: foo-user
PASSWORD: foo-passwd
TEST_USER_3:
FedeAlonso marked this conversation as resolved.
Show resolved Hide resolved
AUTH_TYPE: contributor-auth
USERNAME: contributor-username
PASSWORD: contributor-passwd
OCP_ADMIN_USER:
AUTH_TYPE: adm-auth
USERNAME: adminuser
Expand Down
Loading