-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db47acc
commit c22d598
Showing
8 changed files
with
458 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"meta": { | ||
"count": 1 | ||
}, | ||
"links": { | ||
"first": "/api/automation-hub/_ui/v1/namespaces/?include_related=my_permissions&limit=1&name=test2&offset=0", | ||
"previous": null, | ||
"next": null, | ||
"last": "/api/automation-hub/_ui/v1/namespaces/?include_related=my_permissions&limit=1&name=test2&offset=0" | ||
}, | ||
"data": [ | ||
{ | ||
"pulp_href": "/api/automation-hub/pulp/api/v3/pulp_ansible/namespaces/2/", | ||
"id": 2, | ||
"name": "test2", | ||
"company": "", | ||
"email": "", | ||
"avatar_url": "", | ||
"description": "", | ||
"groups": [ | ||
{ | ||
"id": 1, | ||
"name": "Test Group", | ||
"object_roles": ["galaxy.collection_publisher"] | ||
} | ||
], | ||
"users": [ | ||
{ | ||
"id": 2, | ||
"name": "new-user", | ||
"object_roles": ["galaxy.collection_namespace_owner", "galaxy.collection_publisher"] | ||
}, | ||
{ | ||
"id": 3, | ||
"name": "obj-role-test-user", | ||
"object_roles": ["galaxy.collection_namespace_owner"] | ||
} | ||
], | ||
"related_fields": { | ||
"my_permissions": [ | ||
"galaxy.add_namespace", | ||
"galaxy.change_namespace", | ||
"galaxy.delete_namespace", | ||
"galaxy.upload_to_namespace", | ||
"galaxy.view_namespace" | ||
] | ||
}, | ||
"metadata_sha256": "7e4efa6ba218f9d9a6394bba10d0bb6b452bbe24078bc4b8f62dfe727390dd42", | ||
"avatar_sha256": null | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"count": 1, | ||
"next": null, | ||
"previous": null, | ||
"results": [ | ||
{ | ||
"pulp_href": "/api/automation-hub/pulp/api/v3/roles/018d1319-5a39-77cb-b368-00f504c0889e/", | ||
"pulp_created": "2024-01-16T16:27:25.114238Z", | ||
"name": "galaxy.collection_namespace_owner", | ||
"description": null, | ||
"permissions": ["galaxy.change_namespace", "galaxy.upload_to_namespace"], | ||
"locked": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
frontend/hub/namespaces/HubNamespacePage/HubNamespaceAccessRoles.cy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import * as useHubContext from '../../common/useHubContext'; | ||
import mockUser from '../../../../cypress/fixtures/hub_admin.json'; | ||
import mockNamespaceResponse from '../../../../cypress/fixtures/hub_namespace.json'; | ||
import { hubAPI, pulpAPI } from '../../common/api/formatPath'; | ||
import { HubNamespaceAccessRoles } from './HubNamespaceAccessRoles'; | ||
|
||
describe('HubNamespaceAccessRoles', () => { | ||
beforeEach(() => { | ||
cy.intercept( | ||
{ | ||
method: 'GET', | ||
url: hubAPI`/_ui/v1/namespaces/*`, | ||
}, | ||
mockNamespaceResponse | ||
).as('namespaceDetails'); | ||
}); | ||
it('Roles list renders', () => { | ||
cy.stub(useHubContext, 'useHubContext').callsFake(() => ({ | ||
user: mockUser, | ||
hasPermission: () => true, | ||
})); | ||
cy.mount(<HubNamespaceAccessRoles />, { | ||
path: '/namespaces/:id/users/:username', | ||
initialEntries: ['/namespaces/2/users/new-user'], | ||
}); | ||
cy.get('tbody').find('tr').should('have.length', 2); | ||
}); | ||
it('Role can be expanded to view permissions', () => { | ||
cy.intercept( | ||
{ | ||
method: 'GET', | ||
url: pulpAPI`/roles/*`, | ||
}, | ||
{ | ||
fixture: 'hub_namespace_permissions.json', | ||
} | ||
).as('roleDetails'); | ||
cy.stub(useHubContext, 'useHubContext').callsFake(() => ({ | ||
user: mockUser, | ||
hasPermission: () => true, | ||
featureFlags: {}, | ||
})); | ||
cy.mount(<HubNamespaceAccessRoles />, { | ||
path: '/namespaces/:id/users/:username', | ||
initialEntries: ['/namespaces/2/users/new-user'], | ||
}); | ||
cy.get('#expand-toggle0 > .pf-v5-c-table__toggle-icon').click(); | ||
cy.contains(/^Change and upload collections to namespaces.$/); | ||
cy.contains(/^Change namespace$/); | ||
cy.contains(/^Upload to namespace$/); | ||
}); | ||
it('Filter roles by name', () => { | ||
cy.stub(useHubContext, 'useHubContext').callsFake(() => ({ | ||
user: mockUser, | ||
hasPermission: () => true, | ||
})); | ||
cy.mount(<HubNamespaceAccessRoles />, { | ||
path: '/namespaces/:id/users/:username', | ||
initialEntries: ['/namespaces/2/users/new-user'], | ||
}); | ||
cy.filterTableByText('namespace'); | ||
cy.contains('galaxy.collection_namespace_owner'); | ||
cy.get('tbody').find('tr').should('have.length', 1); | ||
cy.clickButton(/^Clear all filters$/); | ||
}); | ||
it('Add/delete role actions are enabled for a user with permission to edit access for the namespace', () => { | ||
cy.stub(useHubContext, 'useHubContext').callsFake(() => ({ | ||
user: mockUser, | ||
hasPermission: () => true, | ||
})); | ||
cy.mount(<HubNamespaceAccessRoles />, { | ||
path: '/namespaces/:id/users/:username', | ||
initialEntries: ['/namespaces/2/users/new-user'], | ||
}); | ||
cy.contains('a[data-cy="add-role"]', /^Add role$/).should( | ||
'have.attr', | ||
'aria-disabled', | ||
'false' | ||
); | ||
cy.contains('tr', 'galaxy.collection_namespace_owner').within(() => { | ||
cy.get('button.toggle-kebab').click(); | ||
cy.contains('.pf-v5-c-dropdown__menu-item', /^Delete role$/).should( | ||
'have.attr', | ||
'aria-disabled', | ||
'false' | ||
); | ||
}); | ||
}); | ||
it('Add/delete role actions are disabled for a user without permission to edit access for the namespace', () => { | ||
const mockEmptyUsersResponse = { ...mockNamespaceResponse }; | ||
mockEmptyUsersResponse.data[0].related_fields.my_permissions = []; | ||
cy.intercept( | ||
{ | ||
method: 'GET', | ||
url: hubAPI`/_ui/v1/namespaces/*`, | ||
}, | ||
mockEmptyUsersResponse | ||
).as('nonEmptyListWithoutPermissions'); | ||
cy.stub(useHubContext, 'useHubContext').callsFake(() => ({ | ||
user: { ...mockUser, is_superuser: false }, | ||
hasPermission: () => false, | ||
})); | ||
cy.mount(<HubNamespaceAccessRoles />, { | ||
path: '/namespaces/:id/users/:username', | ||
initialEntries: ['/namespaces/2/users/new-user'], | ||
}); | ||
cy.contains('a[data-cy="add-role"]', /^Add role$/).should('have.attr', 'aria-disabled', 'true'); | ||
cy.contains('tr', 'galaxy.collection_namespace_owner').within(() => { | ||
cy.get('button.toggle-kebab').click(); | ||
cy.contains('.pf-v5-c-dropdown__menu-item', /^Delete role$/).should( | ||
'have.attr', | ||
'aria-disabled', | ||
'true' | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
frontend/hub/namespaces/HubNamespacePage/HubNamespaceTeamAccess.cy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import * as useHubContext from '../../common/useHubContext'; | ||
import mockUser from '../../../../cypress/fixtures/hub_admin.json'; | ||
import mockNamespaceResponse from '../../../../cypress/fixtures/hub_namespace.json'; | ||
import { hubAPI } from '../../common/api/formatPath'; | ||
import { HubNamespaceTeamAccess } from './HubNamespaceTeamAccess'; | ||
|
||
describe('HubNamespaceTeamAccess', () => { | ||
describe('Non-empty list', () => { | ||
beforeEach(() => { | ||
cy.intercept( | ||
{ | ||
method: 'GET', | ||
url: hubAPI`/_ui/v1/namespaces/*`, | ||
}, | ||
mockNamespaceResponse | ||
).as('nonEmptyListWithPermissions'); | ||
}); | ||
it('Teams list renders', () => { | ||
cy.stub(useHubContext, 'useHubContext').callsFake(() => ({ | ||
user: mockUser, | ||
hasPermission: () => true, | ||
})); | ||
cy.mount(<HubNamespaceTeamAccess />); | ||
cy.get('tbody').find('tr').should('have.length', 1); | ||
}); | ||
it('Filter teams by name', () => { | ||
cy.stub(useHubContext, 'useHubContext').callsFake(() => ({ | ||
user: mockUser, | ||
hasPermission: () => true, | ||
})); | ||
cy.mount(<HubNamespaceTeamAccess />); | ||
cy.filterTableByText('Test Group'); | ||
cy.contains('Test Group'); | ||
cy.get('tbody').find('tr').should('have.length', 1); | ||
cy.clickButton(/^Clear all filters$/); | ||
}); | ||
it('Add/delete team actions are enabled for a user with permission to edit access for the namespace', () => { | ||
cy.stub(useHubContext, 'useHubContext').callsFake(() => ({ | ||
user: mockUser, | ||
hasPermission: () => true, | ||
})); | ||
cy.mount(<HubNamespaceTeamAccess />); | ||
cy.contains('a[data-cy="add-team"]', /^Add team$/).should( | ||
'have.attr', | ||
'aria-disabled', | ||
'false' | ||
); | ||
cy.contains('tr', 'Test Group').within(() => { | ||
cy.get('button.toggle-kebab').click(); | ||
cy.contains('.pf-v5-c-dropdown__menu-item', /^Delete team$/).should( | ||
'have.attr', | ||
'aria-disabled', | ||
'false' | ||
); | ||
}); | ||
}); | ||
it('Add/delete team actions are disabled for a user without permission to edit access for the namespace', () => { | ||
const mockEmptyUsersResponse = { ...mockNamespaceResponse }; | ||
mockEmptyUsersResponse.data[0].related_fields.my_permissions = []; | ||
cy.intercept( | ||
{ | ||
method: 'GET', | ||
url: hubAPI`/_ui/v1/namespaces/*`, | ||
}, | ||
mockEmptyUsersResponse | ||
).as('nonEmptyListWithoutPermissions'); | ||
cy.stub(useHubContext, 'useHubContext').callsFake(() => ({ | ||
user: { ...mockUser, is_superuser: false }, | ||
hasPermission: () => false, | ||
})); | ||
cy.mount(<HubNamespaceTeamAccess />); | ||
cy.contains('a[data-cy="add-team"]', /^Add team$/).should( | ||
'have.attr', | ||
'aria-disabled', | ||
'true' | ||
); | ||
cy.contains('tr', 'Test Group').within(() => { | ||
cy.get('button.toggle-kebab').click(); | ||
cy.contains('.pf-v5-c-dropdown__menu-item', /^Delete team$/).should( | ||
'have.attr', | ||
'aria-disabled', | ||
'true' | ||
); | ||
}); | ||
}); | ||
}); | ||
describe('Empty list', () => { | ||
it('Empty state is displayed correctly for a user with permissions to add teams', () => { | ||
const mockEmptyUsersResponse = { ...mockNamespaceResponse }; | ||
mockEmptyUsersResponse.data[0].groups = []; | ||
cy.intercept( | ||
{ | ||
method: 'GET', | ||
url: hubAPI`/_ui/v1/namespaces/*`, | ||
}, | ||
mockEmptyUsersResponse | ||
).as('emptyList'); | ||
cy.stub(useHubContext, 'useHubContext').callsFake(() => ({ | ||
user: mockUser, | ||
hasPermission: () => true, | ||
})); | ||
cy.mount(<HubNamespaceTeamAccess />); | ||
cy.contains(/^There are currently no teams added.$/); | ||
cy.contains(/^Please add a team by using the button below.$/); | ||
cy.contains('a', /^Add team$/).should('be.visible'); | ||
cy.contains('a', /^Add team$/).should('not.be.disabled'); | ||
}); | ||
it('Empty state is displayed correctly for user without permission to add teams', () => { | ||
const mockEmptyUsersResponse = { ...mockNamespaceResponse }; | ||
mockEmptyUsersResponse.data[0].groups = []; | ||
mockEmptyUsersResponse.data[0].related_fields.my_permissions = []; | ||
cy.intercept( | ||
{ | ||
method: 'GET', | ||
url: hubAPI`/_ui/v1/namespaces/*`, | ||
}, | ||
mockEmptyUsersResponse | ||
).as('emptyList'); | ||
cy.stub(useHubContext, 'useHubContext').callsFake(() => ({ | ||
user: { ...mockUser, is_superuser: false }, | ||
hasPermission: () => false, | ||
})); | ||
cy.mount(<HubNamespaceTeamAccess />); | ||
cy.contains(/^You do not have permission to add a team.$/); | ||
cy.contains( | ||
/^Please contact your organization administrator if there is an issue with your access.$/ | ||
); | ||
cy.contains('a', /^Add team$/).should('not.exist'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.