diff --git a/cypress/e2e/hub/hub-ee-access.cy.ts b/cypress/e2e/hub/hub-ee-access.cy.ts index 2839c0c798..5efb387e67 100644 --- a/cypress/e2e/hub/hub-ee-access.cy.ts +++ b/cypress/e2e/hub/hub-ee-access.cy.ts @@ -1,12 +1,30 @@ import { RemoteRegistry } from '../../../frontend/hub/administration/remote-registries/RemoteRegistry'; import { ExecutionEnvironment } from '../../../frontend/hub/execution-environments/ExecutionEnvironment'; -// import { hubAPI } from '../../support/formatApiPathForHub'; +import { hubAPI } from '../../support/formatApiPathForHub'; import { ExecutionEnvironments } from './constants'; +import { randomString } from '../../../framework/utils/random-string'; +import { ContentTypeEnum } from '../../../frontend/hub/interfaces/expanded/ContentType'; +import { HubRbacRole } from '../../../frontend/hub/interfaces/expanded/HubRbacRole'; describe.skip('Execution Environment User Access tab', () => { let executionEnvironment: ExecutionEnvironment; let remoteRegistry: RemoteRegistry; + let role: HubRbacRole; before(() => { + const customRole = { + roleName: 'galaxy.' + `${randomString(5)}`, + roleDescription: 'Manage EE.', + contentType: ContentTypeEnum.ExecutionEnvironment, + permission: 'galaxy.view_containernamespace', + }; + cy.createHubRoleAPI({ + roleName: customRole.roleName, + description: customRole.roleDescription, + content_type: customRole.contentType, + permissions: [customRole.permission], + }).then((createdRole) => { + role = createdRole; + }); cy.createHubRemoteRegistry().then((remoteRegistry) => { cy.createHubExecutionEnvironment({ executionEnvironment: { registry: remoteRegistry.id }, @@ -19,6 +37,7 @@ describe.skip('Execution Environment User Access tab', () => { after(() => { cy.deleteHubExecutionEnvironment(executionEnvironment); cy.deleteHubRemoteRegistry(remoteRegistry); + cy.deleteHubRoleAPI(role); }); beforeEach(() => { @@ -29,159 +48,96 @@ describe.skip('Execution Environment User Access tab', () => { cy.verifyPageTitle(executionEnvironment.name); }); - // function removeRoleFromListRow(roleName: string, assignmentType: string) { - // cy.intercept('DELETE', hubAPI`/role_${assignmentType}_assignments/*`).as('deleteRole'); - // cy.clickTableRowPinnedAction(roleName, 'remove-role', false); - // cy.getModal().within(() => { - // cy.get('#confirm').click(); - // cy.clickButton(/^Remove role/); - // cy.wait('@deleteRole') - // .its('response') - // .then((deleted) => { - // expect(deleted?.statusCode).to.eql(204); - // cy.contains(/^Success$/).should('be.visible'); - // cy.containsBy('button', /^Close$/).click(); - // }); - // cy.contains(/^Success$/); - // cy.clickButton(/^Close$/); - // cy.clearAllFilters(); - // }); - // } + function removeRoleFromListRow(roleName: string) { + cy.clickTableRowPinnedAction(roleName, 'remove-role', false); + cy.getModal().within(() => { + cy.get('#confirm').click(); + cy.clickButton(/^Remove role/); + cy.contains(/^Success$/); + cy.clickButton(/^Close$/); + cy.clearAllFilters(); + }); + } - it.skip('create a new ee, from the user access tab assign a user and apply role(s) to the user of the ee', () => { - // cy.intercept('POST', hubAPI`/_ui/v2/role_user_assignments/`).as('userRoleAssignment'); - // cy.createHubUser().then((hubUser) => { - // cy.clickTab('User Access', true); - // cy.getByDataCy('add-roles').click(); - // cy.verifyPageTitle('Add roles'); - // cy.getWizard().within(() => { - // cy.contains('h1', 'Select user(s)').should('be.visible'); - // cy.setTablePageSize('100'); - // cy.selectTableRowByCheckbox('username', hubUser.username, { disableFilter: true }); - // cy.clickButton(/^Next/); - // cy.contains('h1', 'Select roles to apply').should('be.visible'); - // cy.filterTableByTextFilter('name', 'galaxy.execution_environment_collaborator', { - // disableFilterSelection: true, - // }); - // cy.selectTableRowByCheckbox('name', 'galaxy.execution_environment_collaborator', { - // disableFilter: true, - // }); - // cy.filterTableByTextFilter('name', 'galaxy.execution_environment_namespace_owner', { - // disableFilterSelection: true, - // }); - // cy.selectTableRowByCheckbox('name', 'galaxy.execution_environment_namespace_owner', { - // disableFilter: true, - // }); - // cy.filterTableByTextFilter('name', 'galaxy.execution_environment_publisher', { - // disableFilterSelection: true, - // }); - // cy.selectTableRowByCheckbox('name', 'galaxy.execution_environment_publisher', { - // disableFilter: true, - // }); - // cy.clickButton(/^Next/); - // cy.contains('h1', 'Review').should('be.visible'); - // cy.verifyReviewStepWizardDetails('users', [hubUser.username], '1'); - // cy.verifyReviewStepWizardDetails( - // 'hubRoles', - // [ - // 'galaxy.execution_environment_collaborator', - // 'Change existing execution environments.', - // 'galaxy.execution_environment_namespace_owner', - // 'Create and update execution environments under existing container namespaces.', - // 'galaxy.execution_environment_publisher', - // 'Push and change execution environments.', - // ], - // '3' - // ); - // cy.clickButton(/^Finish/); - // cy.wait('@userRoleAssignment') - // .its('response') - // .then((response) => { - // expect(response?.statusCode).to.eql(201); - // }); - // }); - // cy.getModal().within(() => { - // cy.clickButton(/^Close$/); - // }); - // cy.getModal().should('not.exist'); - // cy.verifyPageTitle(executionEnvironment.name); - // cy.selectTableRowByCheckbox('username', hubUser.username, { - // disableFilter: true, - // }); - // removeRoleFromListRow('galaxy.execution_environment_publisher', 'user'); - // cy.selectTableRowByCheckbox('username', hubUser.username, { - // disableFilter: true, - // }); - // removeRoleFromListRow('galaxy.execution_environment_namespace_owner', 'user'); - // cy.deleteHubUser(hubUser, { failOnStatusCode: false }); - // }); + it('create a new ee, from the user access tab assign a user and apply role(s) to the user of the ee', () => { + cy.intercept('POST', hubAPI`/_ui/v2/role_user_assignments/`).as('userRoleAssignment'); + cy.createHubUser().then((hubUser) => { + cy.clickTab('User Access', true); + cy.getByDataCy('add-roles').click(); + cy.getWizard().within(() => { + cy.selectTableRow(hubUser.username); + cy.clickButton(/^Next/); + cy.contains('h1', 'Select roles to apply').should('be.visible'); + cy.filterTableByTextFilter('name', role.name, { + disableFilterSelection: true, + }); + cy.selectTableRowByCheckbox('name', role.name, { + disableFilter: true, + }); + cy.clickButton(/^Next/); + cy.contains('h1', 'Review').should('be.visible'); + cy.verifyReviewStepWizardDetails('users', [hubUser.username], '1'); + cy.verifyReviewStepWizardDetails('hubRoles', [role.name, role.description], '1'); + cy.clickButton(/^Finish/); + cy.wait('@userRoleAssignment') + .its('response') + .then((response) => { + expect(response?.statusCode).to.eql(201); + }); + }); + cy.getModal().within(() => { + cy.clickButton(/^Close$/); + }); + cy.getModal().should('not.exist'); + cy.verifyPageTitle(executionEnvironment.name); + cy.selectTableRowByCheckbox('username', hubUser.username, { + disableFilter: true, + }); + cy.contains(role.name).should('be.visible'); + removeRoleFromListRow(role.name); + cy.deleteHubUser(hubUser, { failOnStatusCode: false }); + }); }); - it.skip('create a new ee, from the team access tab assign a user and apply role(s) to the team of the ee', () => { - // cy.intercept('POST', hubAPI`/_ui/v2/role_team_assignments/`).as('teamRoleAssignment'); - // cy.createHubTeam().then((hubTeam) => { - // cy.clickTab('Team Access', true); - // cy.getByDataCy('add-roles').click(); - // cy.verifyPageTitle('Add roles'); - // cy.getWizard().within(() => { - // cy.contains('h1', 'Select team(s)').should('be.visible'); - // cy.selectTableRowByCheckbox('name', hubTeam.name, { disableFilter: true }); - // cy.clickButton(/^Next/); - // cy.contains('h1', 'Select roles to apply').should('be.visible'); - // cy.filterTableByTextFilter('name', 'galaxy.execution_environment_collaborator', { - // disableFilterSelection: true, - // }); - // cy.selectTableRowByCheckbox('name', 'galaxy.execution_environment_collaborator', { - // disableFilter: true, - // }); - // cy.filterTableByTextFilter('name', 'galaxy.execution_environment_namespace_owner', { - // disableFilterSelection: true, - // }); - // cy.selectTableRowByCheckbox('name', 'galaxy.execution_environment_namespace_owner', { - // disableFilter: true, - // }); - // cy.filterTableByTextFilter('name', 'galaxy.execution_environment_publisher', { - // disableFilterSelection: true, - // }); - // cy.selectTableRowByCheckbox('name', 'galaxy.execution_environment_publisher', { - // disableFilter: true, - // }); - // cy.clickButton(/^Next/); - // cy.contains('h1', 'Review').should('be.visible'); - // cy.verifyReviewStepWizardDetails('teams', [hubTeam.name], '1'); - // cy.verifyReviewStepWizardDetails( - // 'hubRoles', - // [ - // 'galaxy.execution_environment_collaborator', - // 'Change existing execution environments.', - // 'galaxy.execution_environment_namespace_owner', - // 'Create and update execution environments under existing container namespaces.', - // 'galaxy.execution_environment_publisher', - // 'Push and change execution environments.', - // ], - // '3' - // ); - // cy.clickButton(/^Finish/); - // cy.wait('@teamRoleAssignment') - // .its('response') - // .then((response) => { - // expect(response?.statusCode).to.eql(201); - // }); - // }); - // cy.getModal().within(() => { - // cy.clickButton(/^Close$/); - // }); - // cy.getModal().should('not.exist'); - // cy.verifyPageTitle(executionEnvironment.name); - // cy.selectTableRowByCheckbox('name', hubTeam.name, { - // disableFilter: true, - // }); - // removeRoleFromListRow('galaxy.execution_environment_publisher', 'team'); - // cy.selectTableRowByCheckbox('name', hubTeam.name, { - // disableFilter: true, - // }); - // removeRoleFromListRow('galaxy.execution_environment_namespace_owner', 'team'); - // cy.deleteHubTeam(hubTeam, { failOnStatusCode: false }); - // }); + it('create a new ee, from the team access tab assign a user and apply role(s) to the team of the ee', () => { + cy.intercept('POST', hubAPI`/_ui/v2/role_team_assignments/`).as('teamRoleAssignment'); + cy.createHubTeam().then((hubTeam) => { + cy.clickTab('Team Access', true); + cy.getByDataCy('add-roles').click(); + cy.verifyPageTitle('Add roles'); + cy.getWizard().within(() => { + cy.contains('h1', 'Select team(s)').should('be.visible'); + cy.selectTableRowByCheckbox('name', hubTeam.name, { disableFilter: true }); + cy.clickButton(/^Next/); + cy.contains('h1', 'Select roles to apply').should('be.visible'); + cy.filterTableByTextFilter('name', role.name, { + disableFilterSelection: true, + }); + cy.selectTableRowByCheckbox('name', role.name, { + disableFilter: true, + }); + cy.clickButton(/^Next/); + cy.contains('h1', 'Review').should('be.visible'); + cy.verifyReviewStepWizardDetails('teams', [hubTeam.name], '1'); + cy.verifyReviewStepWizardDetails('hubRoles', [role.name, role.description], '1'); + cy.clickButton(/^Finish/); + cy.wait('@teamRoleAssignment') + .its('response') + .then((response) => { + expect(response?.statusCode).to.eql(201); + }); + }); + cy.getModal().within(() => { + cy.clickButton(/^Close$/); + }); + cy.getModal().should('not.exist'); + cy.verifyPageTitle(executionEnvironment.name); + cy.selectTableRowByCheckbox('name', hubTeam.name, { + disableFilter: true, + }); + cy.contains(role.name).should('be.visible'); + removeRoleFromListRow(role.name); + cy.deleteHubTeam(hubTeam, { failOnStatusCode: false }); + }); }); }); diff --git a/cypress/e2e/hub/namespace-access.cy.ts b/cypress/e2e/hub/namespace-access.cy.ts index 5c4d1711e8..41af81179a 100644 --- a/cypress/e2e/hub/namespace-access.cy.ts +++ b/cypress/e2e/hub/namespace-access.cy.ts @@ -1,9 +1,27 @@ import { HubNamespace } from '../../../frontend/hub/namespaces/HubNamespace'; -// import { hubAPI } from '../../support/formatApiPathForHub'; +import { hubAPI } from '../../support/formatApiPathForHub'; +import { randomString } from '../../../framework/utils/random-string'; +import { ContentTypeEnum } from '../../../frontend/hub/interfaces/expanded/ContentType'; +import { HubRbacRole } from '../../../frontend/hub/interfaces/expanded/HubRbacRole'; describe('Namespace - team and user access', () => { let namespace: HubNamespace; + let role: HubRbacRole; + const customRole = { + roleName: 'galaxy.' + `${randomString(5)}`, + roleDescription: 'Manage Namespaces.', + contentType: ContentTypeEnum.Namespace, + permission: 'galaxy.view_namespace', + }; before(() => { + cy.createHubRoleAPI({ + roleName: customRole.roleName, + description: customRole.roleDescription, + content_type: customRole.contentType, + permissions: [customRole.permission], + }).then((createdRole) => { + role = createdRole; + }); cy.createHubNamespace().then((namespaceResult) => { namespace = namespaceResult; }); @@ -11,6 +29,7 @@ describe('Namespace - team and user access', () => { after(() => { cy.deleteHubNamespace({ ...namespace, failOnStatusCode: false }); + cy.deleteHubRoleAPI(role); }); beforeEach(() => { @@ -21,139 +40,94 @@ describe('Namespace - team and user access', () => { cy.clickTableRowLink('name', namespace.name, { disableFilter: true }); }); - // function removeRoleFromListRow(roleName: string, assignmentType: string) { - // cy.intercept('DELETE', hubAPI`/role_${assignmentType}_assignments/*`).as('deleteRole'); - // cy.clickTableRowPinnedAction(roleName, 'remove-role', false); - // cy.getModal().within(() => { - // cy.get('#confirm').click(); - // cy.clickButton(/^Remove role/); - // cy.wait('@deleteRole') - // .its('response') - // .then((deleted) => { - // expect(deleted?.statusCode).to.eql(204); - // cy.contains(/^Success$/).should('be.visible'); - // cy.containsBy('button', /^Close$/).click(); - // }); - // }); - // } + function removeRoleFromListRow(roleName: string) { + cy.clickTableRowPinnedAction(roleName, 'remove-role', false); + cy.getModal().within(() => { + cy.get('#confirm').click(); + cy.clickButton(/^Remove role/); + cy.contains(/^Success$/).should('be.visible'); + cy.containsBy('button', /^Close$/).click(); + }); + } - it.skip('create a new namespace, from the user access tab assign a user and apply role(s) to the user of the namespace', () => { - // cy.intercept('POST', hubAPI`/_ui/v2/role_user_assignments/`).as('userRoleAssignment'); - // cy.createHubUser().then((hubUser) => { - // cy.clickTab('User Access', true); - // cy.getByDataCy('add-roles').click(); - // cy.verifyPageTitle('Add roles'); - // cy.getWizard().within(() => { - // cy.contains('h1', 'Select user(s)').should('be.visible'); - // cy.selectTableRowByCheckbox('username', hubUser.username, { disableFilter: true }); - // cy.clickButton(/^Next/); - // cy.contains('h1', 'Select roles to apply').should('be.visible'); - // cy.filterTableByTextFilter('name', 'galaxy.collection_namespace_owner', { - // disableFilterSelection: true, - // }); - // cy.selectTableRowByCheckbox('name', 'galaxy.collection_namespace_owner', { - // disableFilter: true, - // }); - // cy.filterTableByTextFilter('name', 'galaxy.collection_publisher', { - // disableFilterSelection: true, - // }); - // cy.selectTableRowByCheckbox('name', 'galaxy.collection_publisher', { - // disableFilter: true, - // }); - // cy.clickButton(/^Next/); - // cy.contains('h1', 'Review').should('be.visible'); - // cy.verifyReviewStepWizardDetails('users', [hubUser.username], '1'); - // cy.verifyReviewStepWizardDetails( - // 'hubRoles', - // [ - // 'galaxy.collection_namespace_owner', - // 'Change and upload collections to namespaces.', - // 'galaxy.collection_publisher', - // 'Upload and modify collections.', - // ], - // '2' - // ); - // cy.clickButton(/^Finish/); - // cy.wait('@userRoleAssignment') - // .its('response') - // .then((response) => { - // expect(response?.statusCode).to.eql(201); - // }); - // }); - // cy.getModal().within(() => { - // cy.clickButton(/^Close$/); - // }); - // cy.getModal().should('not.exist'); - // cy.verifyPageTitle(namespace.name); - // cy.selectTableRowByCheckbox('username', hubUser.username, { - // disableFilter: true, - // }); - // removeRoleFromListRow('galaxy.collection_namespace_owner', 'user'); - // cy.selectTableRowByCheckbox('username', hubUser.username, { - // disableFilter: true, - // }); - // removeRoleFromListRow('galaxy.collection_publisher', 'user'); - // cy.deleteHubUser(hubUser, { failOnStatusCode: false }); - // }); + it('create a new namespace, from the user access tab assign a user and apply role(s) to the user of the namespace', () => { + cy.intercept('POST', hubAPI`/_ui/v2/role_user_assignments/`).as('userRoleAssignment'); + cy.createHubUser().then((hubUser) => { + cy.clickTab('User Access', true); + cy.getByDataCy('add-roles').click(); + cy.getWizard().within(() => { + cy.contains('h1', 'Select user(s)').should('be.visible'); + cy.selectTableRow(hubUser.username); + cy.clickButton(/^Next/); + cy.contains('h1', 'Select roles to apply').should('be.visible'); + cy.filterTableByTextFilter('name', role.name, { + disableFilterSelection: true, + }); + cy.selectTableRowByCheckbox('name', role.name, { + disableFilter: true, + }); + cy.clickButton(/^Next/); + cy.contains('h1', 'Review').should('be.visible'); + cy.verifyReviewStepWizardDetails('users', [hubUser.username], '1'); + cy.verifyReviewStepWizardDetails('hubRoles', [role.name, role.description], '1'); + cy.clickButton(/^Finish/); + cy.wait('@userRoleAssignment') + .its('response') + .then((response) => { + expect(response?.statusCode).to.eql(201); + }); + }); + cy.getModal().within(() => { + cy.clickButton(/^Close$/); + }); + cy.getModal().should('not.exist'); + cy.verifyPageTitle(namespace.name); + cy.selectTableRowByCheckbox('username', hubUser.username, { + disableFilter: true, + }); + cy.contains(role.name).should('be.visible'); + removeRoleFromListRow(role.name); + cy.deleteHubUser(hubUser, { failOnStatusCode: false }); + }); }); - it.skip('create a new namespace, from the team access tab assign a user and apply role(s) to the team of the namespace', () => { - // cy.intercept('POST', hubAPI`/_ui/v2/role_team_assignments/`).as('teamRoleAssignment'); - // cy.createHubTeam().then((hubTeam) => { - // cy.clickTab('Team Access', true); - // cy.getByDataCy('add-roles').click(); - // cy.verifyPageTitle('Add roles'); - // cy.getWizard().within(() => { - // cy.contains('h1', 'Select teams(s)').should('be.visible'); - // cy.selectTableRowByCheckbox('name', hubTeam.name, { disableFilter: true }); - // cy.clickButton(/^Next/); - // cy.contains('h1', 'Select roles to apply').should('be.visible'); - // cy.filterTableByTextFilter('name', 'galaxy.collection_namespace_owner', { - // disableFilterSelection: true, - // }); - // cy.selectTableRowByCheckbox('name', 'galaxy.collection_namespace_owner', { - // disableFilter: true, - // }); - // cy.filterTableByTextFilter('name', 'galaxy.collection_publisher', { - // disableFilterSelection: true, - // }); - // cy.selectTableRowByCheckbox('name', 'galaxy.collection_publisher', { - // disableFilter: true, - // }); - // cy.clickButton(/^Next/); - // cy.contains('h1', 'Review').should('be.visible'); - // cy.verifyReviewStepWizardDetails('teams', [hubTeam.name], '1'); - // cy.verifyReviewStepWizardDetails( - // 'hubRoles', - // [ - // 'galaxy.collection_namespace_owner', - // 'Change and upload collections to namespaces.', - // 'galaxy.collection_publisher', - // 'Upload and modify collections.', - // ], - // '2' - // ); - // cy.clickButton(/^Finish/); - // cy.wait('@teamRoleAssignment') - // .its('response') - // .then((response) => { - // expect(response?.statusCode).to.eql(201); - // }); - // }); - // cy.getModal().within(() => { - // cy.clickButton(/^Close$/); - // }); - // cy.getModal().should('not.exist'); - // cy.verifyPageTitle(namespace.name); - // cy.selectTableRowByCheckbox('name', hubTeam.name, { - // disableFilter: true, - // }); - // removeRoleFromListRow('galaxy.collection_namespace_owner', 'team'); - // cy.selectTableRowByCheckbox('name', hubTeam.name, { - // disableFilter: true, - // }); - // removeRoleFromListRow('galaxy.collection_publisher', 'team'); - // cy.deleteHubTeam(hubTeam, { failOnStatusCode: false }); - // }); + it('create a new namespace, from the team access tab assign a user and apply role(s) to the team of the namespace', () => { + cy.intercept('POST', hubAPI`/_ui/v2/role_team_assignments/`).as('teamRoleAssignment'); + cy.createHubTeam().then((hubTeam) => { + cy.clickTab('Team Access', true); + cy.getByDataCy('add-roles').click(); + cy.getWizard().within(() => { + cy.selectTableRow(hubTeam.name); + cy.clickButton(/^Next/); + cy.contains('h1', 'Select roles to apply').should('be.visible'); + cy.filterTableByTextFilter('name', role.name, { + disableFilterSelection: true, + }); + cy.selectTableRowByCheckbox('name', role.name, { + disableFilter: true, + }); + cy.clickButton(/^Next/); + cy.contains('h1', 'Review').should('be.visible'); + cy.verifyReviewStepWizardDetails('teams', [hubTeam.name], '1'); + cy.verifyReviewStepWizardDetails('hubRoles', [role.name, role.description], '1'); + cy.clickButton(/^Finish/); + cy.wait('@teamRoleAssignment') + .its('response') + .then((response) => { + expect(response?.statusCode).to.eql(201); + }); + }); + cy.getModal().within(() => { + cy.clickButton(/^Close$/); + }); + cy.getModal().should('not.exist'); + cy.verifyPageTitle(namespace.name); + cy.selectTableRowByCheckbox('team-name', hubTeam.name, { + disableFilter: false, + }); + cy.contains(role.name).should('be.visible'); + removeRoleFromListRow(role.name); + cy.deleteHubTeam(hubTeam, { failOnStatusCode: false }); + }); }); }); diff --git a/cypress/e2e/hub/remotes-access.cy.ts b/cypress/e2e/hub/remotes-access.cy.ts index 14cfa38b6e..87a734fc21 100644 --- a/cypress/e2e/hub/remotes-access.cy.ts +++ b/cypress/e2e/hub/remotes-access.cy.ts @@ -89,6 +89,7 @@ describe('Remotes User Access tab', () => { cy.selectTableRowByCheckbox('username', hubUser.username, { disableFilter: true, }); + cy.contains(role.name).should('be.visible'); removeRoleFromListRow(role.name); cy.deleteHubUser(hubUser, { failOnStatusCode: false }); }); @@ -131,6 +132,7 @@ describe('Remotes User Access tab', () => { cy.selectTableRowByCheckbox('team-name', hubTeam.name, { disableFilter: false, }); + cy.contains(role.name).should('be.visible'); removeRoleFromListRow(role.name); cy.deleteHubTeam(hubTeam, { failOnStatusCode: false }); });