From aea749d82f92961d58d8e314a433458fbd5b76ee Mon Sep 17 00:00:00 2001 From: Alex <33497058+bexsoft@users.noreply.github.com> Date: Mon, 18 Jul 2022 15:39:14 -0500 Subject: [PATCH] Added Loader in rewind enable function (#2172) Signed-off-by: Benjamin Perez --- .github/workflows/jobs.yaml | 79 +++++++++++++++++++ .../Objects/ListObjects/ListObjects.tsx | 2 +- .../Objects/ListObjects/RewindEnable.tsx | 4 + .../Common/TableWrapper/TableWrapper.tsx | 2 +- portal-ui/tests/constants/timestamp.txt | 2 +- portal-ui/tests/permissions-3/bucketRead.ts | 2 + portal-ui/tests/permissions-9/rewind.ts | 57 +++++++++++++ portal-ui/tests/utils/elements.ts | 19 +++++ 8 files changed, 164 insertions(+), 3 deletions(-) create mode 100644 portal-ui/tests/permissions-9/rewind.ts diff --git a/.github/workflows/jobs.yaml b/.github/workflows/jobs.yaml index 64d443c94..cf931b7f5 100644 --- a/.github/workflows/jobs.yaml +++ b/.github/workflows/jobs.yaml @@ -951,6 +951,85 @@ jobs: with: args: '"chrome:headless" portal-ui/tests/permissions-8/ --skip-js-errors' + all-permissions-9: + name: Permissions Tests Part 9 + needs: + - lint-job + - no-warnings-and-make-assets + - reuse-golang-dependencies + - vulnerable-dependencies-checks + - semgrep-static-code-analysis + runs-on: ${{ matrix.os }} + strategy: + matrix: + go-version: [ 1.18.x ] + os: [ ubuntu-latest ] + steps: + - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }} + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + id: go + - uses: actions/setup-node@v2 + with: + node-version: '16' + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - 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- + + - 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- + + - uses: actions/cache@v2 + name: Go Mod Cache + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ github.run_id }} + + - name: Build Console on ${{ matrix.os }} + env: + GO111MODULE: on + GOOS: linux + run: | + make console + + - name: Start Console, front-end app and initialize users/policies + run: | + (./console server) & (make initialize-permissions) + + - name: Run TestCafe Tests + uses: DevExpress/testcafe-action@latest + with: + args: '"chrome:headless" portal-ui/tests/permissions-9/ --skip-js-errors -c 3' + + - name: Clean up users & policies + run: | + make cleanup-permissions + all-operator-tests: name: Operator UI Tests needs: diff --git a/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx b/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx index f3d285360..46a93e0dc 100644 --- a/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx +++ b/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx @@ -1416,7 +1416,7 @@ const ListObjects = () => { }} disabled={ !isVersioned || - !hasPermission(bucketName, [IAM_SCOPES.S3_PUT_OBJECT]) + !hasPermission(bucketName, [IAM_SCOPES.S3_GET_OBJECT]) } /> {!rewindEnableButton && rewindEnabled ? "Show Current Data" diff --git a/portal-ui/src/screens/Console/Common/TableWrapper/TableWrapper.tsx b/portal-ui/src/screens/Console/Common/TableWrapper/TableWrapper.tsx index d2a36a9dd..7fe1c46dc 100644 --- a/portal-ui/src/screens/Console/Common/TableWrapper/TableWrapper.tsx +++ b/portal-ui/src/screens/Console/Common/TableWrapper/TableWrapper.tsx @@ -779,7 +779,7 @@ const TableWrapper = ({ ) : ( {!isLoading && ( -
+
{customEmptyMessage !== "" ? customEmptyMessage : `There are no ${entityName} yet.`} diff --git a/portal-ui/tests/constants/timestamp.txt b/portal-ui/tests/constants/timestamp.txt index b18812c2e..5702a5136 100644 --- a/portal-ui/tests/constants/timestamp.txt +++ b/portal-ui/tests/constants/timestamp.txt @@ -1 +1 @@ -1653008276 +1657924012 diff --git a/portal-ui/tests/permissions-3/bucketRead.ts b/portal-ui/tests/permissions-3/bucketRead.ts index 31a1f2ce2..e0f5f3661 100644 --- a/portal-ui/tests/permissions-3/bucketRead.ts +++ b/portal-ui/tests/permissions-3/bucketRead.ts @@ -89,7 +89,9 @@ test await t .useRole(roles.bucketRead) .navigateTo("http://localhost:9090/buckets") + .wait(2000) .click(testBucketBrowseButtonFor("bucketread3")) + .wait(2000) .expect(elements.table.exists) .ok(); }) diff --git a/portal-ui/tests/permissions-9/rewind.ts b/portal-ui/tests/permissions-9/rewind.ts new file mode 100644 index 000000000..f85bc892c --- /dev/null +++ b/portal-ui/tests/permissions-9/rewind.ts @@ -0,0 +1,57 @@ +// 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 . + +import * as roles from "../utils/roles"; +import * as elements from "../utils/elements"; +import * as functions from "../utils/functions"; +import { testBucketBrowseButtonFor } from "../utils/functions"; + +fixture("Rewind Testing").page("http://localhost:9090"); + +test + .before(async (t) => { + // Create a bucket + await functions.setUpBucket(t, "abucketrewind"); + await functions.setVersioned(t, "abucketrewind"); + await t + .useRole(roles.bucketReadWrite) + .navigateTo("http://localhost:9090/buckets") + .click(testBucketBrowseButtonFor("abucketrewind")) + // Upload object to bucket + .setFilesToUpload(elements.uploadInput, "../uploads/test.txt") + .wait(1000) + .navigateTo("http://localhost:9090/buckets") + .click(testBucketBrowseButtonFor("abucketrewind")) + // Upload object to bucket + .setFilesToUpload(elements.uploadInput, "../uploads/test.txt") + .wait(1000); + })("Rewind works in bucket", async (t) => { + await t + .useRole(roles.bucketReadWrite) + .navigateTo("http://localhost:9090/buckets") + .click(testBucketBrowseButtonFor("abucketrewind")) + .expect(elements.table.exists) + .ok() + .click(elements.rewindButton) + .expect(elements.rewindToInput.exists) + .ok() + .typeText(elements.rewindToInput, "01/01/2015 00:00") + .click(elements.rewindDataButton); + }) + .after(async (t) => { + // Cleanup created bucket and corresponding uploads + await functions.cleanUpBucketAndUploads(t, "abucketrewind"); + }); diff --git a/portal-ui/tests/utils/elements.ts b/portal-ui/tests/utils/elements.ts index c0cbf4e9c..1ff824c38 100644 --- a/portal-ui/tests/utils/elements.ts +++ b/portal-ui/tests/utils/elements.ts @@ -214,3 +214,22 @@ export const nodeSelector = Selector('[data-test-id="node-selector"]'); // User Details //---------------------------------------------------- export const userPolicies = Selector(".MuiTab-root").withText("Policies"); +//---------------------------------------------------- +// Rewind Options +//---------------------------------------------------- +export const rewindButton = Selector("button").withAttribute( + "id", + "rewind-objects-list" +); +export const rewindToInput = Selector("input").withAttribute( + "id", + "rewind-selector" +); +export const rewindDataButton = Selector("button").withAttribute( + "id", + "rewind-apply-button" +); +export const locationEmpty = Selector("div").withAttribute( + "id", + "empty-results" +);