github.com/minio/console@v1.4.1/web-app/tests/permissions-3/bucketRead.ts (about) 1 // This file is part of MinIO Console Server 2 // Copyright (c) 2022 MinIO, Inc. 3 // 4 // This program is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Affero General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Affero General Public License for more details. 13 // 14 // You should have received a copy of the GNU Affero General Public License 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17 import * as roles from "../utils/roles"; 18 import * as elements from "../utils/elements"; 19 import * as functions from "../utils/functions"; 20 import { bucketsElement, logoutItem } from "../utils/elements-menu"; 21 import { testBucketBrowseButtonFor } from "../utils/functions"; 22 import { Selector } from "testcafe"; 23 import * as constants from "../utils/constants"; 24 25 fixture("For user with Bucket Read permissions") 26 .page("http://localhost:9090") 27 .beforeEach(async (t) => { 28 await t.useRole(roles.bucketRead); 29 }); 30 31 test("Buckets sidebar item exists", async (t) => { 32 const bucketsExist = bucketsElement.exists; 33 await t.expect(bucketsExist).ok(); 34 }); 35 36 test 37 .before(async (t) => { 38 // Create a bucket 39 await functions.setUpBucket(t, "bucketread1"); 40 })("Browse button exists", async (t) => { 41 await new Promise((resolve) => setTimeout(resolve, 2000)); 42 await t 43 .useRole(roles.bucketRead) 44 .navigateTo("http://localhost:9090/browser") 45 .expect(testBucketBrowseButtonFor("bucketread1").exists) 46 .ok(); 47 }) 48 .after(async (t) => { 49 // Cleanup created bucket and corresponding uploads 50 await functions.cleanUpBucket(t, "bucketread1"); 51 }); 52 53 test 54 .before(async (t) => { 55 // Create a bucket 56 await functions.setUpBucket(t, "bucketread2"); 57 })("Bucket access is set to R", async (t) => { 58 await new Promise((resolve) => setTimeout(resolve, 2000)); 59 await t 60 .useRole(roles.bucketRead) 61 .navigateTo("http://localhost:9090/buckets") 62 .expect( 63 Selector(`#access-${constants.TEST_BUCKET_NAME}-bucketread2`).innerText, 64 ) 65 .eql("Access: R"); 66 }) 67 .after(async (t) => { 68 // Cleanup created bucket and corresponding uploads 69 await functions.cleanUpBucket(t, "bucketread2"); 70 }); 71 72 test 73 .before(async (t) => { 74 // Create a bucket 75 await functions.setUpBucket(t, "aread3"); 76 await t 77 .useRole(roles.admin) 78 .navigateTo("http://localhost:9090/browser") 79 .click(testBucketBrowseButtonFor("aread3")) 80 // Upload object to bucket 81 .setFilesToUpload(elements.uploadInput, "../uploads/test.txt") 82 .click(logoutItem); 83 })("Object list table is enabled", async (t) => { 84 await new Promise((resolve) => setTimeout(resolve, 2000)); 85 await t 86 .useRole(roles.bucketRead) 87 .navigateTo("http://localhost:9090/browser") 88 .wait(2000) 89 .click(testBucketBrowseButtonFor("aread3")) 90 .wait(2000) 91 .expect(elements.table.exists) 92 .ok(); 93 }) 94 .after(async (t) => { 95 // Cleanup created bucket and corresponding uploads 96 await functions.cleanUpBucketAndUploads(t, "aread3"); 97 });