Fixed UI Tests (#3471)

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
Alex
2024-11-11 18:49:47 -06:00
committed by GitHub
parent 2ca484c691
commit 97ef82f831
13 changed files with 23 additions and 398 deletions

View File

@@ -537,101 +537,6 @@ jobs:
timeout-minutes: 5
run: npx testcafe "firefox:headless" web-app/tests/permissions-6/ --skip-js-errors
all-permissions-7:
name: Permissions Tests Part 7
needs:
- compile-binary
runs-on: [ubuntu-latest]
strategy:
matrix:
go-version: [1.22.x]
os: [ubuntu-latest]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Read .nvmrc
id: node_version
run: echo "$(cat .nvmrc)" && echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_ENV
- name: Enable Corepack
run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NVMRC }}
- name: Install MinIO JS
working-directory: ./
continue-on-error: false
run: |
yarn add minio
- uses: actions/cache@v4
name: Console Binary Cache
with:
path: |
./console
key: ${{ runner.os }}-binary-${{ github.run_id }}
- name: clean-previous-containers-if-any
run: |
docker stop minio || true;
docker container prune -f || true;
- name: Start Console, front-end app and initialize users/policies
run: |
(./console server) & (make initialize-permissions)
- name: Install TestCafe
run: npm install testcafe@3.5.0
- name: Run TestCafe Tests
timeout-minutes: 5
run: npx testcafe "firefox:headless" web-app/tests/permissions-7/ --skip-js-errors
all-permissions-8:
name: Permissions Tests Part 8
needs:
- compile-binary
runs-on: [ubuntu-latest]
strategy:
matrix:
go-version: [1.22.x]
os: [ubuntu-latest]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Read .nvmrc
id: node_version
run: echo "$(cat .nvmrc)" && echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_ENV
- name: Enable Corepack
run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NVMRC }}
- name: Install MinIO JS
working-directory: ./
continue-on-error: false
run: |
yarn add minio
- uses: actions/cache@v4
name: Console Binary Cache
with:
path: |
./console
key: ${{ runner.os }}-binary-${{ github.run_id }}
- name: clean-previous-containers-if-any
run: |
docker stop minio || true;
docker container prune -f || true;
- name: Start Console, front-end app and initialize users/policies
run: |
(./console server) & (make initialize-permissions)
- name: Install TestCafe
run: npm install testcafe@3.5.0
- name: Run TestCafe Tests
timeout-minutes: 5
run: npx testcafe "firefox:headless" web-app/tests/permissions-8/ --skip-js-errors
all-permissions-A:
name: Permissions Tests Part A
needs:

View File

@@ -216,11 +216,6 @@ test-permissions-6:
@(env bash $(PWD)/web-app/tests/scripts/permissions.sh "web-app/tests/permissions-6/")
@(docker stop minio)
test-permissions-7:
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{1...4})
@(env bash $(PWD)/web-app/tests/scripts/permissions.sh "web-app/tests/permissions-7/")
@(docker stop minio)
test-apply-permissions:
@(env bash $(PWD)/web-app/tests/scripts/initialize-env.sh)

View File

@@ -1,53 +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/>.
package integration
import (
"fmt"
"log"
"net/http"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestTiersList(t *testing.T) {
assert := assert.New(t)
// image for now:
// minio: 9000
// console: 9090
client := &http.Client{
Timeout: 2 * time.Second,
}
request, err := http.NewRequest("GET", "http://localhost:9090/api/v1/admin/tiers", nil)
if err != nil {
log.Println(err)
return
}
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
request.Header.Add("Content-Type", "application/json")
response, err := client.Do(request)
assert.NotNil(response, "Tiers List response is nil")
assert.Nil(err, "Tiers List errored out")
assert.Equal(response.StatusCode, 200)
}

View File

@@ -1,68 +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 * as roles from "../utils/roles";
import * as elements from "../utils/elements";
import { monitoringElement, traceElement } from "../utils/elements-menu";
import { Selector } from "testcafe";
export const traceStartButton = Selector('[data-test-id="trace-start-button"]');
export const traceStopButton = Selector('[data-test-id="trace-stop-button"]');
fixture("For user with Trace permissions")
.page("http://localhost:9090")
.beforeEach(async (t) => {
await t.useRole(roles.trace);
});
test("Monitoring sidebar item exists", async (t) => {
await t.expect(monitoringElement.exists).ok();
});
test("Trace link exists in Monitoring menu", async (t) => {
await t
.expect(monitoringElement.exists)
.ok()
.click(monitoringElement)
.expect(traceElement.exists)
.ok();
});
test("Trace page can be opened", async (t) => {
await t.navigateTo("http://localhost:9090/tools/trace");
});
test("Start button can be clicked", async (t) => {
await t
.navigateTo("http://localhost:9090/tools/trace")
.click(traceStartButton);
});
test("Stop button appears after Start button has been clicked", async (t) => {
const stopButtonExists = traceStopButton.exists;
await t
.navigateTo("http://localhost:9090/tools/trace")
.click(traceStartButton)
.expect(stopButtonExists)
.ok();
});
test("Stop button can be clicked after Start button has been clicked", async (t) => {
await t
.navigateTo("http://localhost:9090/tools/trace")
.click(traceStartButton)
.click(traceStopButton);
});

View File

@@ -1,154 +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 { Role, Selector } from "testcafe";
import { readFileSync } from "fs";
import { IAM_PAGES } from "../../src/common/SecureComponent/permissions";
import { inspectElement, monitoringElement } from "../utils/elements-menu";
const data = readFileSync(__dirname + "/../constants/timestamp.txt", "utf-8");
const $TIMESTAMP = data.trim();
let testDomainUrl = "http://localhost:9090";
let insAllowedAccKey = `inspect-allowed-${$TIMESTAMP}`;
let insAllowedSeckey = "insallowed1234";
let insNotAllowedAccKey = `inspect-not-allowed-${$TIMESTAMP}`;
let insNotAllowedSeckey = "insnotallowed1234";
/* Begin Local Testing config block */
// For local Testing Create users and assign policies then update here.
// Command to invoke the test locally: testcafe chrome tests/permissions/inspect.ts
/*
testDomainUrl = "http://localhost:5005";
insAllowedAccKey = `all-actions`;
insAllowedSeckey = "minio123";
insNotAllowedAccKey = `deny-admin`;
insNotAllowedSeckey = "minio123";
*/
/* End Local Testing config block */
const loginUrl = `${testDomainUrl}/login`;
const inspectScreenUrl = `${testDomainUrl}${IAM_PAGES.SUPPORT_INSPECT}`;
const loginSubmitBtn = Selector("button").withAttribute("id", "do-login");
export const inspectEl = Selector(".MuiPaper-root")
.find("ul")
.child("#inspect");
export const inspect_volume_input = Selector("#inspect_volume");
export const inspect_path_input = Selector("#inspect_path");
export const inspect_volume_input_err =
Selector("#inspect_volume").sibling("div.errorText");
export const inspect_path_input_err =
Selector("#inspect_path").sibling("div.errorText");
export const inspect_encrypt_input = Selector("#inspect_encrypt");
export const inspect_form_clear_btn = Selector(
'[data-test-id="inspect-clear-button"]',
);
export const inspect_form_submit_btn = Selector(
'[data-test-id="inspect-submit-button"]',
);
/** Begin Allowed Policy Test **/
export const inspectAllowedRole = Role(
loginUrl,
async (t) => {
await t
.typeText("#accessKey", insAllowedAccKey)
.typeText("#secretKey", insAllowedSeckey)
.click(loginSubmitBtn);
},
{ preserveUrl: true },
);
fixture("For user with Inspect permissions")
.page(testDomainUrl)
.beforeEach(async (t) => {
await t.useRole(inspectAllowedRole);
});
test("Inspect page can be opened", async (t) => {
await t.navigateTo(inspectScreenUrl);
});
test("Inspect link exists in Menu list", async (t) => {
await t.useRole(inspectAllowedRole).expect(inspectElement.exists).ok();
});
test("Form Input states verification", async (t) => {
const volumeValue = "test";
const pathValue = "test.txt/xl.meta";
await t.navigateTo(inspectScreenUrl);
//Initial state verification
await t.expect(inspect_volume_input.value).eql("");
await t.expect(inspect_path_input.value).eql("");
await t.expect(inspect_form_submit_btn.hasAttribute("disabled")).ok();
await t.expect(inspect_encrypt_input.hasAttribute("checked")).ok();
await t
.expect(inspect_volume_input_err.innerText)
.eql("This field is required");
await t
.expect(inspect_path_input_err.innerText)
.eql("This field is required");
});
/** End Allowed Policy Test **/
/** Begin Not Allowed Policy Test **/
export const inspectNotAllowedRole = Role(
loginUrl,
async (t) => {
await t
.typeText("#accessKey", insNotAllowedAccKey)
.typeText("#secretKey", insNotAllowedSeckey)
.click(loginSubmitBtn);
},
{ preserveUrl: true },
);
fixture("For user with Denied Inspect permissions")
.page(testDomainUrl)
.beforeEach(async (t) => {
await t.useRole(inspectNotAllowedRole);
});
test("Inspect page can NOT be opened", async (t) => {
try {
await t.navigateTo(inspectScreenUrl);
} catch (e) {
await t.expect(e).ok();
}
});
test("Inspect link should NOT exists in Menu list", async (t) => {
await t
.expect(monitoringElement.exists)
.ok()
.click(monitoringElement)
.expect(inspectEl.exists)
.notOk(
"Inspect Link should not exist in the menu list as per inspect not allowed policy",
);
});
/** End Not Allowed Policy Test **/

View File

@@ -24,7 +24,7 @@ import {
testBucketBrowseButtonFor,
} from "../utils/functions";
import { Selector } from "testcafe";
import { deniedError, file } from "../permissions-6/resourceTesting";
import { deniedError, file } from "../permissions-4/resourceTesting";
fixture("Rewind Testing").page("http://localhost:9090");

View File

@@ -33,28 +33,6 @@ export const getSubmenuBlock = (item) => {
//----------------------------------------------------
export const logoutItem = getMenuElement("sign-out");
//----------------------------------------------------
// Specific sidebar elements
//----------------------------------------------------
export const monitoringElement = getMenuElement("tools");
export const monitoringChildren = getSubmenuBlock("tools");
export const dashboardElement = monitoringChildren
.find("button")
.withAttribute("id", "monitorMetrics");
export const logsElement = monitoringChildren
.find("button")
.withAttribute("id", "monitorLogs");
export const traceElement = monitoringChildren
.find("button")
.withAttribute("id", "monitorTrace");
export const drivesElement = monitoringChildren
.find("button")
.withAttribute("id", "monitorDrives");
export const watchElement = monitoringChildren
.find("button")
.withAttribute("id", "monitorWatch");
export const bucketsElement = getMenuElement("buckets");
export const serviceAcctsElement = getMenuElement("nav-accesskeys");
@@ -78,3 +56,25 @@ export const notificationEndpointsElement = getMenuElement("lambda");
export const inspectElement = getMenuElement("inspectObjects");
export const licenseElement = getMenuElement("license");
//----------------------------------------------------
// Specific sidebar elements
//----------------------------------------------------
export const monitoringElement = getMenuElement("tools");
export const monitoringChildren = getSubmenuBlock("tools");
export const dashboardElement = monitoringChildren
.find("button")
.withAttribute("id", "monitorMetrics");
export const logsElement = monitoringChildren
.find("button")
.withAttribute("id", "monitorLogs");
export const traceElement = monitoringChildren
.find("button")
.withAttribute("id", "monitorTrace");
export const drivesElement = monitoringChildren
.find("button")
.withAttribute("id", "monitorDrives");
export const watchElement = monitoringChildren
.find("button")
.withAttribute("id", "monitorWatch");