Adding delete versions test (#1701)

adding delete versions ui test
This commit is contained in:
adfost
2022-03-15 14:40:48 -07:00
committed by GitHub
parent b0119a55df
commit 75bc568e4b
5 changed files with 95 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
// 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 * as functions from "../utils/functions";
import { bucketsElement } from "../utils/elements-menu";
import { testBucketBrowseButtonFor } from "../utils/functions";
import { Selector } from "testcafe";
import * as constants from "../utils/constants";
fixture("For user with Bucket Read & Write permissions").page("http://localhost:9090");
test
.before(async (t) => {
// Create a bucket
await functions.setUpBucket(t, "bucketdelete3");
await functions.setVersioned(t, "bucketdelete3");
})("All versions of an object can be deleted from a bucket", async (t) => {
const testBucketBrowseButton = testBucketBrowseButtonFor("bucketdelete3");
await t
.useRole(roles.bucketReadWrite)
.navigateTo("http://localhost:9090/buckets")
.click(testBucketBrowseButton)
// Upload object to bucket
.setFilesToUpload(elements.uploadInput, "../uploads/test.txt")
.wait(1000)
.click("div.ReactVirtualized__Grid.ReactVirtualized__Table__Grid > div > div:nth-child(1)")
.click(elements.deleteButton)
.click(elements.switchInput)
.click(Selector("button:enabled").withExactText("Delete").nth(1))
.expect(Selector("div.ReactVirtualized__Grid.ReactVirtualized__Table__Grid > div > div:nth-child(1)").exists).notOk()
}).after(async (t) => {
// Cleanup created bucket and corresponding uploads
await functions.cleanUpBucketAndUploads(t, "bucketdelete3");
});

View File

@@ -0,0 +1,14 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::*"
]
}
]
}

View File

@@ -26,6 +26,7 @@ create_policies() {
mc admin policy add minio bucketassignpolicy-$TIMESTAMP portal-ui/tests/policies/bucketAssignPolicy.json
mc admin policy add minio bucketread-$TIMESTAMP portal-ui/tests/policies/bucketRead.json
mc admin policy add minio bucketwrite-$TIMESTAMP portal-ui/tests/policies/bucketWrite.json
mc admin policy add minio bucketreadwrite-$TIMESTAMP portal-ui/tests/policies/bucketReadWrite.json
mc admin policy add minio bucketspecific-$TIMESTAMP portal-ui/tests/policies/bucketSpecific.json
mc admin policy add minio dashboard-$TIMESTAMP portal-ui/tests/policies/dashboard.json
mc admin policy add minio diagnostics-$TIMESTAMP portal-ui/tests/policies/diagnostics.json
@@ -49,6 +50,7 @@ create_users() {
mc admin user add minio bucketassignpolicy-$TIMESTAMP bucketassignpolicy
mc admin user add minio bucketread-$TIMESTAMP bucketread
mc admin user add minio bucketwrite-$TIMESTAMP bucketwrite
mc admin user add minio bucketreadwrite-$TIMESTAMP bucketreadwrite
mc admin user add minio bucketspecific-$TIMESTAMP bucketspecific
mc admin user add minio dashboard-$TIMESTAMP dashboard
mc admin user add minio diagnostics-$TIMESTAMP diagnostics
@@ -76,6 +78,7 @@ assign_policies() {
mc admin policy set minio bucketassignpolicy-$TIMESTAMP user=bucketassignpolicy-$TIMESTAMP
mc admin policy set minio bucketread-$TIMESTAMP user=bucketread-$TIMESTAMP
mc admin policy set minio bucketwrite-$TIMESTAMP user=bucketwrite-$TIMESTAMP
mc admin policy set minio bucketreadwrite-$TIMESTAMP user=bucketreadwrite-$TIMESTAMP
mc admin policy set minio bucketspecific-$TIMESTAMP user=bucketspecific-$TIMESTAMP
mc admin policy set minio dashboard-$TIMESTAMP user=dashboard-$TIMESTAMP
mc admin policy set minio diagnostics-$TIMESTAMP user=diagnostics-$TIMESTAMP

View File

@@ -40,6 +40,24 @@ export const setUpNamedBucket = (t, name) => {
});
};
export const setVersioned = (t, modifier) => {
return setVersionedBucket(t, `${constants.TEST_BUCKET_NAME}-${modifier}`);
};
export const setVersionedBucket = (t, name) => {
const minioClient = new Minio.Client({
endPoint: "localhost",
port: 9000,
useSSL: false,
accessKey: "minioadmin",
secretKey: "minioadmin",
});
return new Promise((resolve, reject) => {
minioClient.setBucketVersioning(name, {Status:"Enabled"}).then(resolve).catch(resolve);
});
};
export const namedManageButtonFor = (name) => {
return Selector("h1")
.withText(name)

View File

@@ -53,6 +53,17 @@ export const bucketWrite = Role(
{ preserveUrl: true }
);
export const bucketReadWrite = Role(
loginUrl,
async (t) => {
await t
.typeText("#accessKey", "bucketreadwrite-" + unixTimestamp)
.typeText("#secretKey", "bucketreadwrite")
.click(submitButton);
},
{ preserveUrl: true }
);
export const bucketSpecific = Role(
loginUrl,
async (t) => {