Delete test tenants after tests are done (#2033)

This commit is contained in:
Javier Adriel
2022-05-25 15:54:03 -05:00
committed by GitHub
parent 6866b84da8
commit 9844269c1a
3 changed files with 83 additions and 35 deletions

View File

@@ -359,6 +359,7 @@ const TenantDetails = ({ classes, match, history }: ITenantDetailsProps) => {
actions={
<div>
<BoxIconButton
id={"delete-tenant"}
tooltip={"Delete"}
variant="outlined"
aria-label="Delete"

View File

@@ -14,48 +14,20 @@
// 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";
import { loginToOperator, createTenant, createTenantWithoutAuditLog, deleteTenant } from './utils';
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("#close")
.expect(Selector(`#list-tenant-${tenantName}`).exists)
.ok();
await loginToOperator();
await createTenant(tenantName);
await deleteTenant(tenantName);
});
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("#enableLogging")
.click("#wizard-button-Create")
.wait(1000)
.click("#close")
.expect(Selector(`#list-tenant-${tenantName}`).exists)
.ok();
await loginToOperator();
await createTenantWithoutAuditLog(tenantName);
await deleteTenant(tenantName);
});

View File

@@ -0,0 +1,75 @@
// 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, t } from 'testcafe';
export const loginToOperator = async () => {
await t
.navigateTo("http://localhost:9090/login")
.typeText("#jwt", "anyrandompasswordwillwork")
.click("#do-login");
}
export const createTenant = async (tenantName: string) => {
await fillTenantInformation(tenantName);
await t.click("#wizard-button-Create");
await checkTenantExists(tenantName);
}
export const createTenantWithoutAuditLog = async (tenantName) => {
await fillTenantInformation(tenantName);
await t
.click("#wizard-step-audit-log")
.click("#enableLogging")
.click("#wizard-button-Create");
await checkTenantExists(tenantName);
}
const fillTenantInformation = async (tenantName: string) => {
await t
.click("#create-tenant")
.typeText("#tenant-name", tenantName)
.typeText("#namespace", tenantName)
.click("#add-namespace")
.click("#confirm-ok")
.wait(1000);
}
const checkTenantExists = async (tenantName) => {
await t
.wait(1000)
.click("#close")
.expect(Selector(`#list-tenant-${tenantName}`).exists)
.ok();
}
export const deleteTenant = async (tenantName: string) => {
await goToTenant(tenantName);
await t
.click("#delete-tenant")
.typeText("#retype-tenant", tenantName)
.click("#confirm-ok")
.expect(Selector(`#list-tenant-${tenantName}`).exists)
.notOk();
}
const goToTenant = async (tenantName) => {
await t.click(Selector(`#list-tenant-${tenantName}`))
}