Skip to content

Commit

Permalink
Admin - Model Registry RBAC Management Projects
Browse files Browse the repository at this point in the history
  • Loading branch information
ppadti committed Aug 8, 2024
1 parent 3aeb340 commit 5dad9b8
Show file tree
Hide file tree
Showing 14 changed files with 501 additions and 54 deletions.
3 changes: 3 additions & 0 deletions frontend/src/__mocks__/mockRoleBindingK8sResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type MockResourceConfigType = {
roleRefName?: string;
uid?: string;
modelRegistryName?: string;
isProjectSubject?: boolean;
};

export const mockRoleBindingK8sResource = ({
Expand All @@ -22,6 +23,7 @@ export const mockRoleBindingK8sResource = ({
],
roleRefName = 'view',
uid = genUID('rolebinding'),
isProjectSubject = false,
modelRegistryName = '',
}: MockResourceConfigType): RoleBindingKind => {
let labels;
Expand All @@ -33,6 +35,7 @@ export const mockRoleBindingK8sResource = ({
'app.kubernetes.io/part-of': 'model-registry',
[KnownLabels.DASHBOARD_RESOURCE]: 'true',
component: 'model-registry',
...(isProjectSubject && { [KnownLabels.PROJECT_SUBJECT]: 'true' }),
};
} else {
labels = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,35 @@ import { TableRow } from './components/table';

class PermissionsTableRow extends TableRow {}

class UsersTab {
class UsersTab extends Contextual<HTMLElement> {
findAddUserButton() {
return this.find().findByTestId('add-button user');
}

findAddGroupButton() {
return this.find().findByTestId('add-button group');
}

getUserTable() {
return new PermissionTable(() => this.find().findByTestId('role-binding-table User'));
}

getGroupTable() {
return new PermissionTable(() => this.find().findByTestId('role-binding-table Group'));
}
}

class ProjectsTab extends Contextual<HTMLElement> {
findAddProjectButton() {
return this.find().findByTestId('add-button project');
}

getProjectTable() {
return new PermissionTable(() => this.find().findByTestId('role-binding-table Group'));
}
}

class MRPermissions {
visit(mrName: string, wait = true) {
cy.visitWithLogin(`/modelRegistrySettings/permissions/${mrName}`);
if (wait) {
Expand All @@ -16,20 +44,16 @@ class UsersTab {
cy.testA11y();
}

findAddUserButton() {
return cy.findByTestId('add-button User');
}

findAddGroupButton() {
return cy.findByTestId('add-button Group');
findProjectTab() {
return cy.findByTestId('projects-tab');
}

getUserTable() {
return new PermissionTable(() => cy.findByTestId('role-binding-table User'));
getUsersContent() {
return new UsersTab(() => cy.findByTestId('users-tab-content'));
}

getGroupTable() {
return new PermissionTable(() => cy.findByTestId('role-binding-table Group'));
getProjectsContent() {
return new ProjectsTab(() => cy.findByTestId('projects-tab-content'));
}
}

Expand All @@ -46,7 +70,7 @@ class PermissionTable extends Contextual<HTMLElement> {
return this.find().findByTestId(['role-binding-name-input', id]);
}

findGroupSelect() {
findNameSelect() {
return this.find().get(`[aria-label="Name selection"]`);
}

Expand All @@ -69,4 +93,4 @@ class PermissionTable extends Contextual<HTMLElement> {
}
}

export const usersTab = new UsersTab();
export const modelRegistryPermissions = new MRPermissions();
4 changes: 2 additions & 2 deletions frontend/src/__tests__/cypress/cypress/pages/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class PermissionsTab {
}

findAddUserButton() {
return cy.findByTestId('add-button User');
return cy.findByTestId('add-button user');
}

findAddGroupButton() {
return cy.findByTestId('add-button Group');
return cy.findByTestId('add-button group');
}

getUserTable() {
Expand Down
Loading

0 comments on commit 5dad9b8

Please sign in to comment.