Skip to content

Commit d9531f9

Browse files
Fix the Admin UI Tests (#1423)
* Fix the Admin UI Tests Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> * concurrency * Fix heal tests Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> * fix Logs and trace Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> * Fix tests that weren't passing * concurrency Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> Co-authored-by: Kaan Kabalak <kaan@minio.io>
1 parent 18c14cc commit d9531f9

File tree

36 files changed

+467
-254
lines changed

36 files changed

+467
-254
lines changed

.github/workflows/permissions.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,23 @@ jobs:
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
matrix:
17-
go-version: [1.17.x]
18-
os: [ubuntu-latest]
17+
go-version: [ 1.17.x ]
18+
os: [ ubuntu-latest ]
1919
steps:
2020
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
2121
uses: actions/setup-go@v2
2222
with:
2323
go-version: ${{ matrix.go-version }}
2424
id: go
25-
25+
- uses: actions/setup-node@v2
26+
with:
27+
node-version: '17'
2628
- name: Check out code into the Go module directory
2729
uses: actions/checkout@v2
2830

31+
- name: Make assets
32+
run: |
33+
make assets
2934
- name: Build Console on ${{ matrix.os }}
3035
env:
3136
GO111MODULE: on
@@ -35,12 +40,12 @@ jobs:
3540
3641
- name: Start Console, front-end app and initialize users/policies
3742
run: |
38-
(./console server && sleep 180) & (cd portal-ui && yarn && yarn start && sleep 180) & (make initialize-permissions && sleep 180)
43+
(./console server && sleep 180) & (make initialize-permissions && sleep 180)
3944
4045
- name: Run TestCafe Tests
4146
uses: DevExpress/testcafe-action@latest
4247
with:
43-
args: '"chrome:headless" portal-ui/tests/permissions/ --skip-js-errors'
48+
args: '"chrome:headless" portal-ui/tests/permissions/ --skip-js-errors '
4449

4550
- name: Clean up users & policies
4651
run: |

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,15 @@ test-permissions:
7676
@(env bash $(PWD)/portal-ui/tests/scripts/permissions.sh)
7777
@(docker stop minio)
7878

79-
initialize-permissions:
80-
@(docker run -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{1...4})
79+
test-apply-permissions:
8180
@(env bash $(PWD)/portal-ui/tests/scripts/initialize-env.sh)
8281

82+
test-start-docker-minio:
83+
@(docker run -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{1...4})
84+
85+
initialize-permissions: test-start-docker-minio test-apply-permissions
86+
@echo "Done initializing permissions test"
87+
8388
cleanup-permissions:
8489
@(env bash $(PWD)/portal-ui/tests/scripts/cleanup-env.sh)
8590
@(docker stop minio)

portal-ui/src/common/SecureComponent/permissions.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,8 @@ export const IAM_PAGES = {
170170
TOOLS_DIAGNOSTICS: "/support/diagnostics",
171171
TOOLS_SPEEDTEST: "/support/speedtest",
172172
CALL_HOME: "/support/call-home",
173-
INSPECT: "/support/inspect",
174173
PROFILE: "/support/profile",
175-
TOOLS_WATCH: "/support/watch",
174+
TOOLS_WATCH: "/support/inspect",
176175

177176
/** License **/
178177
LICENSE: "/license",
@@ -389,7 +388,6 @@ export const IAM_PAGES_PERMISSIONS = {
389388
[IAM_PAGES.TOOLS_SPEEDTEST]: [IAM_SCOPES.ADMIN_HEALTH_INFO],
390389
[IAM_PAGES.REGISTER_SUPPORT]: [IAM_SCOPES.ADMIN_HEALTH_INFO],
391390
[IAM_PAGES.CALL_HOME]: [IAM_SCOPES.ADMIN_HEALTH_INFO],
392-
[IAM_PAGES.INSPECT]: [IAM_SCOPES.ADMIN_HEALTH_INFO],
393391
[IAM_PAGES.PROFILE]: [IAM_SCOPES.ADMIN_HEALTH_INFO],
394392
[IAM_PAGES.HEALTH]: [IAM_SCOPES.ADMIN_HEALTH_INFO],
395393
};

portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,10 @@ const ListObjects = ({
13161316
<Grid item xs={12}>
13171317
<br />
13181318
</Grid>
1319-
<div {...getRootProps({ style: { ...dndStyles } })}>
1319+
<div
1320+
id="object-list-wrapper"
1321+
{...getRootProps({ style: { ...dndStyles } })}
1322+
>
13201323
<input {...getInputProps()} />
13211324
<Grid item xs={12} className={classes.tableBlock}>
13221325
<SecureComponent

portal-ui/src/screens/Console/Configurations/ConfigurationPanels/ConfigurationOptions.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ const ConfigurationOptions = ({ classes, match }: IConfigurationOptions) => {
8080

8181
<PageLayout>
8282
<Grid item xs={12}>
83-
<div className={classes.settingsOptionsContainer}>
83+
<div
84+
id="settings-container"
85+
className={classes.settingsOptionsContainer}
86+
>
8487
<ScreenTitle icon={<SettingsIcon />} title={"Configuration:"} />
8588
<VerticalTabs
8689
selectedTab={selConfigTab}

portal-ui/src/screens/Console/Console.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ const Console = ({
322322
},
323323
{
324324
component: Tools,
325-
path: IAM_PAGES.INSPECT,
325+
path: IAM_PAGES.TOOLS_WATCH,
326326
},
327327
{
328328
component: Tools,

portal-ui/src/screens/Console/Groups/GroupsDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ const GroupsDetails = ({ classes }: IGroupDetailsProps) => {
290290
actions={
291291
<Fragment>
292292
<span className={classes.statusLabel}>Group Status:</span>
293-
<span className={classes.statusValue}>
293+
<span id="group-status" className={classes.statusValue}>
294294
{isGroupEnabled ? "Enabled" : "Disabled"}
295295
</span>
296296
<SecureComponent

portal-ui/src/screens/Console/Logs/ErrorLogs/ErrorLogs.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,9 @@ const ErrorLogs = ({
334334
<SearchBox placeholder="Highlight Line" onChange={setHighlight} />
335335
</Grid>
336336
<Grid item xs={12}>
337-
<div className={classes.logList}>{renderLines}</div>
337+
<div id="logs-container" className={classes.logList}>
338+
{renderLines}
339+
</div>
338340
</Grid>
339341
</Grid>
340342
</PageLayout>

portal-ui/src/screens/Console/Menu/ConsoleMenuList.tsx

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ import {
3030
import { DocumentationIcon, SettingsIcon } from "../../../icons";
3131
import MenuItem from "./MenuItem";
3232
import { NavLink, useLocation } from "react-router-dom";
33-
import { IAM_PAGES } from "../../../common/SecureComponent/permissions";
33+
import {
34+
CONSOLE_UI_RESOURCE,
35+
IAM_PAGES,
36+
IAM_SCOPES,
37+
} from "../../../common/SecureComponent/permissions";
38+
import SecureComponent from "../../../common/SecureComponent/SecureComponent";
3439

3540
const ConsoleMenuList = ({
3641
menuItems,
@@ -106,6 +111,7 @@ const ConsoleMenuList = ({
106111
stateClsName={stateClsName}
107112
page={menuGroup}
108113
key={menuGroup.id}
114+
id={menuGroup.id}
109115
onExpand={setOpenGroup}
110116
expandedValue={openGroup}
111117
pathValue={pathname}
@@ -131,34 +137,39 @@ const ConsoleMenuList = ({
131137
}}
132138
className={`${stateClsName} group-wrapper bottom-list`}
133139
>
134-
<ListItem
135-
key={IAM_PAGES.SETTINGS}
136-
button
137-
to={IAM_PAGES.SETTINGS}
138-
disableRipple
139-
component={NavLink}
140-
className={`$ ${stateClsName} bottom-menu-item`}
141-
sx={{
142-
...menuItemContainerStyles,
143-
...menuItemMiniStyles,
144-
marginBottom: "3px",
145-
}}
140+
<SecureComponent
141+
scopes={[IAM_SCOPES.ADMIN_CONFIG_UPDATE]}
142+
resource={CONSOLE_UI_RESOURCE}
146143
>
147-
<ListItemIcon
144+
<ListItem
145+
key={IAM_PAGES.SETTINGS}
146+
button
147+
to={IAM_PAGES.SETTINGS}
148+
disableRipple
149+
component={NavLink}
150+
className={`$ ${stateClsName} bottom-menu-item`}
148151
sx={{
149-
...menuItemIconStyles,
152+
...menuItemContainerStyles,
153+
...menuItemMiniStyles,
154+
marginBottom: "3px",
150155
}}
151156
>
152-
<SettingsIcon />
153-
</ListItemIcon>
154-
<ListItemText
155-
primary="Settings"
156-
sx={{
157-
...menuItemTextStyles,
158-
}}
159-
className={stateClsName}
160-
/>
161-
</ListItem>
157+
<ListItemIcon
158+
sx={{
159+
...menuItemIconStyles,
160+
}}
161+
>
162+
<SettingsIcon />
163+
</ListItemIcon>
164+
<ListItemText
165+
primary="Settings"
166+
sx={{
167+
...menuItemTextStyles,
168+
}}
169+
className={stateClsName}
170+
/>
171+
</ListItem>
172+
</SecureComponent>
162173

163174
<ListItem
164175
button

portal-ui/src/screens/Console/Menu/Menu.tsx

Lines changed: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,36 +43,35 @@ import {
4343
} from "../../../icons";
4444

4545
import {
46-
UsersMenuIcon,
47-
BucketsMenuIcon,
48-
IdentityMenuIcon,
49-
MonitoringMenuIcon,
50-
HealthMenuIcon,
51-
GroupsMenuIcon,
46+
AccessMenuIcon,
5247
AccountsMenuIcon,
53-
MetricsMenuIcon,
54-
LogsMenuIcon,
5548
AuditLogsMenuIcon,
56-
TraceMenuIcon,
49+
BucketsMenuIcon,
5750
DrivesMenuIcon,
58-
AccessMenuIcon,
59-
SupportMenuIcon,
51+
GroupsMenuIcon,
52+
HealthMenuIcon,
53+
IdentityMenuIcon,
54+
LogsMenuIcon,
55+
MetricsMenuIcon,
56+
MonitoringMenuIcon,
6057
PerformanceMenuIcon,
61-
InspectMenuIcon,
62-
ProfileMenuIcon,
58+
SupportMenuIcon,
59+
TraceMenuIcon,
60+
UsersMenuIcon,
6361
} from "../../../icons/SidebarMenus/MenuIcons";
6462
import {
6563
CONSOLE_UI_RESOURCE,
6664
IAM_PAGES,
67-
S3_ALL_RESOURCES,
65+
IAM_PAGES_PERMISSIONS,
6866
IAM_SCOPES,
67+
S3_ALL_RESOURCES,
6968
} from "../../../common/SecureComponent/permissions";
7069
import { hasPermission } from "../../../common/SecureComponent/SecureComponent";
7170
import MenuToggle from "./MenuToggle";
7271
import ConsoleMenuList from "./ConsoleMenuList";
7372
import RegisterMenuIcon from "../../../icons/SidebarMenus/RegisterMenuIcon";
7473
import DiagnosticsMenuIcon from "../../../icons/SidebarMenus/DiagnosticsMenuIcon";
75-
import CallHomeMenuIcon from "../../../icons/SidebarMenus/CallHomeMenuIcon";
74+
import InspectMenuIcon from "../../../icons/SidebarMenus/InspectMenuIcon";
7675

7776
const drawerWidth = 245;
7877

@@ -146,7 +145,7 @@ const Menu = ({
146145

147146
const ldapIsEnabled = (features && features.includes("ldap-idp")) || false;
148147

149-
let consoleMenus = [
148+
let consoleMenus: IMenuItem[] = [
150149
{
151150
name: "Buckets",
152151
id: "buckets",
@@ -196,8 +195,6 @@ const Menu = ({
196195
id: "access",
197196
to: IAM_PAGES.POLICIES,
198197
icon: AccessMenuIcon,
199-
forceDisplay: true,
200-
children: [],
201198
},
202199
{
203200
component: NavLink,
@@ -290,27 +287,27 @@ const Menu = ({
290287
icon: PerformanceMenuIcon,
291288
to: IAM_PAGES.TOOLS_SPEEDTEST,
292289
},
293-
{
294-
name: "Call Home",
295-
id: "callhome",
296-
component: NavLink,
297-
icon: CallHomeMenuIcon,
298-
to: IAM_PAGES.CALL_HOME,
299-
},
290+
// {
291+
// name: "Call Home",
292+
// id: "callhome",
293+
// component: NavLink,
294+
// icon: CallHomeMenuIcon,
295+
// to: IAM_PAGES.CALL_HOME,
296+
// },
300297
{
301298
name: "Inspect",
302-
id: "inspsect",
299+
id: "inspect",
303300
component: NavLink,
304301
icon: InspectMenuIcon,
305-
to: IAM_PAGES.INSPECT,
306-
},
307-
{
308-
name: "Profile",
309-
id: "profile",
310-
component: NavLink,
311-
icon: ProfileMenuIcon,
312-
to: IAM_PAGES.PROFILE,
302+
to: IAM_PAGES.TOOLS_WATCH,
313303
},
304+
// {
305+
// name: "Profile",
306+
// id: "profile",
307+
// component: NavLink,
308+
// icon: ProfileMenuIcon,
309+
// to: IAM_PAGES.PROFILE,
310+
// },
314311
],
315312
},
316313
{
@@ -371,8 +368,40 @@ const Menu = ({
371368
},
372369
];
373370

371+
const allowedItems = (operatorMode ? operatorMenus : consoleMenus).filter(
372+
(item: IMenuItem) => {
373+
if (item.children && item.children.length > 0) {
374+
const c = item.children?.filter((childItem: IMenuItem) => {
375+
return (
376+
((childItem.customPermissionFnc
377+
? childItem.customPermissionFnc()
378+
: hasPermission(
379+
CONSOLE_UI_RESOURCE,
380+
IAM_PAGES_PERMISSIONS[childItem.to ?? ""]
381+
)) ||
382+
childItem.forceDisplay) &&
383+
!childItem.fsHidden
384+
);
385+
});
386+
return c.length > 0;
387+
}
388+
389+
const res =
390+
((item.customPermissionFnc
391+
? item.customPermissionFnc()
392+
: hasPermission(
393+
CONSOLE_UI_RESOURCE,
394+
IAM_PAGES_PERMISSIONS[item.to ?? ""]
395+
)) ||
396+
item.forceDisplay) &&
397+
!item.fsHidden;
398+
return res;
399+
}
400+
);
401+
374402
return (
375403
<Drawer
404+
id="app-menu"
376405
variant="permanent"
377406
className={clsx(classes.drawer, {
378407
[classes.drawerOpen]: sidebarOpen,
@@ -394,7 +423,7 @@ const Menu = ({
394423
/>
395424

396425
<ConsoleMenuList
397-
menuItems={operatorMode ? operatorMenus : consoleMenus}
426+
menuItems={allowedItems}
398427
isOpen={sidebarOpen}
399428
onLogoutClick={logout}
400429
/>

0 commit comments

Comments
 (0)