Testcafe: Add tenant without audit log (#1644)

This commit is contained in:
Daniel Valdivia
2022-03-01 16:39:42 -08:00
committed by GitHub
parent cd72c535d0
commit f92f3e3382
13 changed files with 144 additions and 85 deletions

View File

@@ -20,8 +20,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
go-version: [ 1.17.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
@@ -63,6 +63,7 @@ jobs:
repository: minio/operator
path: operator
- uses: actions/cache@v2
name: Go Mod Cache
with:
path: |
~/.cache/go-build
@@ -77,25 +78,35 @@ jobs:
- uses: actions/cache@v2
id: yarn-cache
name: Yarn Cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
./portal-ui/node_modules/
./portal-ui/build/
key: ${{ runner.os }}-yarn-${{ hashFiles('./portal-ui/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
working-directory: ./
run: make assets
- uses: actions/cache@v2
id: assets-cache
name: Assets Cache
with:
path: |
./portal-ui/build/
key: ${{ runner.os }}-assets-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-assets-
- name: Install Dependencies
working-directory: ./portal-ui
continue-on-error: false
run: |
yarn install
- name: Check for Warnings in build output
working-directory: ./portal-ui
continue-on-error: false
run: |
chmod +x check-warnings.sh && ./check-warnings.sh
./check-warnings.sh
compile-job:
name: Compiles on Go ${{ matrix.go-version }} and ${{ matrix.os }}
@@ -106,8 +117,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
go-version: [ 1.17.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
@@ -134,8 +145,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
go-version: [ 1.17.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
@@ -162,8 +173,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
go-version: [ 1.17.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
@@ -190,8 +201,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
go-version: [ 1.17.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
@@ -218,8 +229,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
go-version: [ 1.17.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
@@ -246,8 +257,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
go-version: [ 1.17.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
@@ -274,8 +285,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
go-version: [ 1.17.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
@@ -302,8 +313,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
go-version: [ 1.17.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
@@ -331,7 +342,7 @@ jobs:
strategy:
matrix:
go-version: [1.17.x]
go-version: [ 1.17.x ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -416,6 +427,7 @@ jobs:
repository: minio/operator
path: operator
- uses: actions/cache@v2
name: Go Mod Cache
with:
path: |
~/.cache/go-build
@@ -430,19 +442,24 @@ jobs:
- uses: actions/cache@v2
id: yarn-cache
name: Yarn Cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
./portal-ui/node_modules/
./portal-ui/build/
key: ${{ runner.os }}-yarn-${{ hashFiles('./portal-ui/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
working-directory: ./
run: make assets
- uses: actions/cache@v2
id: assets-cache
name: Assets Cache
with:
path: |
./portal-ui/build/
key: ${{ runner.os }}-assets-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-assets-
- name: Build Console on ${{ matrix.os }}
env:
@@ -484,6 +501,7 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- uses: actions/cache@v2
name: Go Mod Cache
with:
path: |
~/.cache/go-build
@@ -498,6 +516,7 @@ jobs:
- uses: actions/cache@v2
id: yarn-cache
name: Yarn Cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
@@ -507,10 +526,15 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
working-directory: ./
run: make assets
- uses: actions/cache@v2
id: assets-cache
name: Assets Cache
with:
path: |
./portal-ui/build/
key: ${{ runner.os }}-assets-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-assets-
- name: Build Console on ${{ matrix.os }}
env:

View File

@@ -11,7 +11,7 @@ die() {
try() { "$@" &> yarn.log || die "cannot $*"; }
rm yarn.log
try yarn build
try make build-static
if cat yarn.log | grep "Compiled with warnings"; then
echo "There are warnings in the code"

View File

@@ -153,6 +153,7 @@ const FormSwitchWrapper = ({
disableFocusRipple
disableTouchRipple
value={value}
id={id}
/>
{!switchOnly && (
<span

View File

@@ -55,6 +55,7 @@ interface InputBoxProps {
placeholder?: string;
min?: string;
max?: string;
overlayId?: string;
overlayIcon?: any;
overlayAction?: () => void;
overlayObject?: any;
@@ -125,6 +126,7 @@ const InputBoxWrapper = ({
placeholder = "",
min,
max,
overlayId,
overlayIcon = null,
overlayObject = null,
extraInputProps = {},
@@ -215,6 +217,7 @@ const InputBoxWrapper = ({
}
: () => null
}
id={overlayId}
size={"small"}
disableFocusRipple={false}
disableRipple={false}

View File

@@ -165,7 +165,9 @@ const GenericWizard = ({
{wizardSteps.map((step, index) => {
return (
<ListItem
id={"wizard-step-" + step.label}
id={
"wizard-step-" + step.label.toLowerCase().replaceAll(" ", "-")
}
button
disableRipple
onClick={() => pageChange(index)}

View File

@@ -95,6 +95,7 @@ const ConfirmDialog = ({
{...cancelButtonProps}
variant="outlined"
color="primary"
id={"confirm-cancel"}
>
{cancelText}
</Button>
@@ -110,6 +111,7 @@ const ConfirmDialog = ({
loadingPosition="start"
startIcon={<React.Fragment />}
autoFocus
id={"confirm-ok"}
{...confirmButtonProps}
>
{confirmText}

View File

@@ -260,8 +260,8 @@ const ConfigLogSearch = ({
<Grid item xs={12} className={classes.configSectionItem}>
<FormSwitchWrapper
value="logSearchConfig"
id="log_search_configuration"
name="log_search_configuration"
id="log-search-enabled"
name="log_search_enabled"
checked={logSearchEnabled}
onChange={(e) => {
const targetD = e.target;

View File

@@ -321,6 +321,7 @@ const NameTenantMain = ({
label="Namespace"
value={namespace}
error={validationErrors["namespace"] || ""}
overlayId={"add-namespace"}
overlayIcon={showCreateButton ? <AddIcon /> : null}
overlayAction={addNamespace}
required

View File

@@ -160,7 +160,7 @@ const TenantListItem = ({ tenant, classes }: ITenantListItem) => {
return (
<Fragment>
<div className={classes.tenantItem}>
<div className={classes.tenantItem} id={`list-tenant-${tenant.name}`}>
<Grid container>
<Grid item xs={8}>
<div className={classes.title}>{tenant.name}</div>

View File

@@ -436,6 +436,7 @@ const Login = ({
type="submit"
variant="contained"
color="primary"
id="do-login"
className={classes.submit}
disabled={secretKey === "" || accessKey === "" || loginSending}
>
@@ -459,6 +460,7 @@ const Login = ({
type="submit"
variant="contained"
color="primary"
id="sso-login"
className={classes.submit}
>
Login with SSO
@@ -502,6 +504,7 @@ const Login = ({
type="submit"
variant="contained"
color="primary"
id="do-login"
className={classes.submit}
disabled={jwt === "" || loginSending}
>
@@ -534,6 +537,7 @@ const Login = ({
endIcon={<RefreshIcon />}
color={"primary"}
variant="outlined"
id="retry"
className={classes.retryButton}
>
Retry

View File

@@ -1,41 +0,0 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import { diagnosticsElement, supportElement } from "../utils/elements-menu";
import { Selector } from "testcafe";
fixture("For user with default permissions").page("http://localhost:9090");
test("Create Tenant and List Tenants", async (t) => {
const osCount = Selector(
`#root > div > main > div[class] > div > div > div > div:nth-child(1) > div > div > div`
).count;
await t
.navigateTo("http://localhost:9090/login")
.typeText("#jwt", "anyrandompasswordwillwork")
.click("button.MuiButton-root")
.click(
Selector('button[tabindex="0"][type="button"]').withText("Create Tenant")
)
.typeText("#tenant-name", "thufeb1754epm")
.typeText("#namespace", "default")
.wait(2000)
.click('button[tabindex="0"]:nth-of-type(2)')
.click(Selector('button[tabindex="0"][type="button"]').withText("Done"))
.expect(osCount)
.eql(2);
});

View File

@@ -0,0 +1,61 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import { Selector } from "testcafe";
fixture("For user with default permissions").page("http://localhost:9090");
test("Create Tenant and List Tenants", async (t) => {
const tenantName = `tenant-${Math.floor(Math.random() * 10000)}`;
await t
.navigateTo("http://localhost:9090/login")
.typeText("#jwt", "anyrandompasswordwillwork")
.click("#do-login")
.click("#create-tenant")
.typeText("#tenant-name", tenantName)
.typeText("#namespace", tenantName)
.click("#add-namespace")
.click("#confirm-ok")
.wait(1000)
.click("#wizard-button-Create")
.wait(1000)
.click("#done-button")
.expect(Selector(`#list-tenant-${tenantName}`).exists)
.ok();
});
test("Create Tenant Without Audit Log", async (t) => {
const tenantName = `tenant-${Math.floor(Math.random() * 10000)}`;
await t
.navigateTo("http://localhost:9090/login")
.typeText("#jwt", "anyrandompasswordwillwork")
.click("#do-login")
.click("#create-tenant")
.typeText("#tenant-name", tenantName)
.typeText("#namespace", tenantName)
.click("#add-namespace")
.click("#confirm-ok")
.wait(1000)
.click("#wizard-step-audit-log")
.click("#log-search-enabled")
.click("#wizard-button-Create")
.wait(1000)
.click("#done-button")
.expect(Selector(`#list-tenant-${tenantName}`).exists)
.ok();
});

View File

@@ -16,6 +16,8 @@
import { Role, Selector } from "testcafe";
import { readFileSync } from "fs";
import { IAM_PAGES } from "../../src/common/SecureComponent/permissions";
import { monitoringElement } from "../utils/elements-menu";
const data = readFileSync(__dirname + "/../constants/timestamp.txt", "utf-8");
const $TIMESTAMP = data.trim();
@@ -48,12 +50,12 @@ const loginSubmitBtn = Selector("form button");
export const supportSidebarEl = Selector(".MuiPaper-root")
.find("ul")
.child("#tools");
.child("#support");
export const supportChildren = Selector("#tools-children");
export const supportChildren = Selector("#support-children");
export const inspectEl = supportChildren
.find("a")
.withAttribute("href", "/tools/inspect");
.withAttribute("href", IAM_PAGES.TOOLS_INSPECT);
export const inspect_volume_input = Selector('[data-test-id="inspect_volume"]');
export const inspect_path_input = Selector('[data-test-id="inspect_path"]');
@@ -190,9 +192,9 @@ test("Inspect page can NOT be opened", async (t) => {
test("Inspect link should NOT exists in Menu list", async (t) => {
await t
.expect(supportSidebarEl.exists)
.expect(monitoringElement.exists)
.ok()
.click(supportSidebarEl)
.click(monitoringElement)
.expect(inspectEl.exists)
.notOk(
"Inspect Link should not exist in the menu list as per inspect not allowed policy"