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

migrate e2e test for adding group permission #3683

Merged
Show file tree
Hide file tree
Changes from 4 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
19 changes: 19 additions & 0 deletions frontend/src/__tests__/cypress/cypress/pages/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@ class PermissionTable extends Contextual<HTMLElement> {
.click();
}

addGroupName(name: string) {
const userNameCell = permissions.getGroupTable().find().find('[data-label="Username"]');
userNameCell.findByRole('button', { name: 'Typeahead menu toggle' }).should('exist').click();
userNameCell.children().first().type(`${name}`);
//have to do this at top level `cy` because it goes to top of dom
cy.findByRole('option', { name: `Select "${name}"` }).click();
}

selectAdminOption() {
permissions
.getGroupTable()
.find()
.find('[data-label="Permission"]')
.children()
.first()
.findSelectOption('Admin Edit the project and manage user access')
.click();
}

findSaveNewButton() {
return this.find().findByTestId(['save-new-button']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { projectDetails, projectListPage } from '~/__tests__/cypress/cypress/pag
import { permissions } from '~/__tests__/cypress/cypress/pages/permissions';
import {
HTPASSWD_CLUSTER_ADMIN_USER,
LDAP_CONTRIBUTOR_GROUP,
LDAP_CONTRIBUTOR_USER,
} from '~/__tests__/cypress/cypress/utils/e2eUsers';
import { loadDSPFixture } from '~/__tests__/cypress/cypress/utils/dataLoader';
import { createCleanProject } from '~/__tests__/cypress/cypress/utils/projectChecker';
import { deleteOpenShiftProject } from '~/__tests__/cypress/cypress/utils/oc_commands/project';

describe('Verify that users can provide admin project permissions to non-admin users', () => {
describe('Verify that users can provide admin project permissions to non-admin users/groups', () => {
let testData: DataScienceProjectData;
let projectName: string;

Expand Down Expand Up @@ -39,7 +40,9 @@ 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',
{ tags: ['@Smoke', '@SmokeSet1', '@ODS-2194', '@ODS-2201', '@Dashboard', '@Tier1'] },
{
tags: ['@Smoke', '@SmokeSet1', '@ODS-2194', '@ODS-2201', '@ODS-2208', '@Dashboard'],
},
() => {
// Authentication and navigation
cy.step('Log into the application');
Expand Down Expand Up @@ -71,9 +74,41 @@ describe('Verify that users can provide admin project permissions to non-admin u
cy.contains(LDAP_CONTRIBUTOR_USER.USERNAME).should('exist');
},
);
it(
'Verify user can assign access permissions to user group',
{
tags: ['@Smoke', '@SmokeSet1', '@ODS-2194', '@ODS-2201', '@ODS-2208', '@Dashboard'],
},
() => {
// Authentication and navigation
cy.step('Log into the application');
cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER);

// Project navigation, add group and provide admin permissions
cy.step(
`Navigate to the Project list tab and search for ${testData.projectPermissionResourceName}`,
);
projectListPage.navigate();
projectListPage.filterProjectByName(testData.projectPermissionResourceName);
projectListPage.findProjectLink(testData.projectPermissionResourceName).click();
projectDetails.findSectionTab('permissions').click();

cy.step('Assign admin group Project Permissions');
permissions.findAddGroupButton().click();
permissions.getGroupTable().addGroupName(LDAP_CONTRIBUTOR_GROUP.USERNAME);
permissions.getGroupTable().selectAdminOption();
cy.step(
`Save the group and validate that ${LDAP_CONTRIBUTOR_GROUP.USERNAME} has been saved with admin permissions`,
);
permissions.getGroupTable().findSaveNewButton().should('exist').and('be.visible').click();
cy.contains(LDAP_CONTRIBUTOR_GROUP.USERNAME).should('exist');
},
);
it(
'Verify that user can access the created project with Admin rights',
{ tags: ['@Smoke', '@SmokeSet1', '@ODS-2194', '@ODS-2201', '@Dashboard', '@Tier1'] },
{
tags: ['@Smoke', '@SmokeSet1', '@ODS-2194', '@ODS-2201', '@ODS-2208', '@Dashboard'],
},
() => {
// Authentication and navigation
cy.step(`Log into the application with ${LDAP_CONTRIBUTOR_USER.USERNAME}`);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/__tests__/cypress/cypress/utils/e2eUsers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { UserAuthConfig } from '~/__tests__/cypress/cypress/types';

export const LDAP_CONTRIBUTOR_USER: UserAuthConfig = Cypress.env('LDAP_CONTRIBUTOR_USER');
export const LDAP_CONTRIBUTOR_GROUP: UserAuthConfig = Cypress.env('LDAP_CONTRIBUTOR_GROUP');
export const HTPASSWD_CLUSTER_ADMIN_USER: UserAuthConfig = Cypress.env(
'HTPASSWD_CLUSTER_ADMIN_USER',
);
7 changes: 7 additions & 0 deletions frontend/src/__tests__/cypress/cypress/utils/testConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ const LDAP_CONTRIBUTOR_USER: UserAuthConfig = testConfig?.TEST_USER_3 ?? {
PASSWORD: env.TEST_USER_3_PASSWORD || '',
};

const LDAP_CONTRIBUTOR_GROUP: UserAuthConfig = testConfig?.TEST_USER_3 ?? {
AUTH_TYPE: env.TEST_USER_3_AUTH_TYPE || '',
USERNAME: `${env.TEST_USER_3_USERNAME ?? ''}-group`,
PASSWORD: env.TEST_USER_3_PASSWORD || '',
};

const HTPASSWD_CLUSTER_ADMIN_USER: UserAuthConfig = testConfig?.OCP_ADMIN_USER ?? {
AUTH_TYPE: env.ADMIN_USER_AUTH_TYPE || '',
USERNAME: env.ADMIN_USER_USERNAME || '',
Expand Down Expand Up @@ -73,6 +79,7 @@ const PIP_TRUSTED_HOST = testConfig?.PIP_TRUSTED_HOST;
// spread the cypressEnv variables into the cypress config
export const cypressEnv = {
LDAP_CONTRIBUTOR_USER,
LDAP_CONTRIBUTOR_GROUP,
HTPASSWD_CLUSTER_ADMIN_USER,
AWS_PIPELINES,
TEST_NAMESPACE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const RoleBindingPermissionsNameInput: React.FC<RoleBindingPermissionsNameInputP
}
return (
<TypeaheadSelect
dataTestId={`role-binding-name-select ${value}`}
isScrollable
selectOptions={selectOptions}
selected={value}
Expand Down