Skip to content

Commit

Permalink
Merge branch 'bugfix/ZKUI-187' into q/1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
bert-e committed Jun 7, 2022
2 parents dd430eb + f536c21 commit b09da17
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenko-ui",
"version": "1.4.7",
"version": "1.4.8",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
38 changes: 38 additions & 0 deletions src/react/account/__tests__/Accounts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,44 @@ describe('Accounts', () => {
}
});

it('should not redirect the user to buckets when storage manager and no roles can be assumed', async () => {
try {
//S
const mockedHistory = createMemoryHistory();
mockedHistory.replace = jest.fn();
jest.spyOn(router, 'useHistory').mockReturnValue(mockedHistory);
server.use(
rest.post(`${TEST_API_BASE_URL}/`, (req, res, ctx) =>
res(
ctx.json({
IsTruncated: false,
Accounts: [],
}),
),
),
);

//E
reduxRender(<Accounts />, {
uiErrors: initialErrorsUIState,
networkActivity: {
counter: 0,
messages: List.of(),
},
oidc: { user: { access_token: 'token', profile: {groups: 'StorageManager'} } },
auth: { config: { iamEndpoint: TEST_API_BASE_URL } },
});
//V
expect(mockedHistory.replace).not.toHaveBeenCalled();
} catch (e) {
console.log(
'should list accounts display an error when retrieval of accounts failed',
e,
);
throw e;
}
});

it('should display Create Account Button for Storage Manager', async () => {
try {
//E
Expand Down
6 changes: 5 additions & 1 deletion src/react/utils/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ export const useAccounts = () => {
const dispatch = useDispatch();
const history = useHistory();
const location = useLocation();
const userGroups = useSelector(
(state: AppState) => state.oidc.user?.profile?.groups || [],
);

const { data } = useAwsPaginatedEntities<WebIdentityRoles, Account, ApiError>(
{
Expand Down Expand Up @@ -195,7 +198,8 @@ export const useAccounts = () => {
if (
!canAssumeAdminAccountRolesOnAnyAccount &&
!location.pathname.includes('bucket') &&
!location.pathname.includes('workflows')
!location.pathname.includes('workflows') &&
!userGroups.includes('StorageManager')
) {
history.replace('/buckets');
}
Expand Down

0 comments on commit b09da17

Please sign in to comment.