github.com/minio/console@v1.4.1/web-app/tests/permissions-2/bucketWrite.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 } 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 Write permissions").page("http://localhost:9090"); 26 27 test("Buckets sidebar item exists", async (t) => { 28 const bucketsExist = bucketsElement.with({ boundTestRun: t }).exists; 29 await t.useRole(roles.bucketWrite).expect(bucketsExist).ok(); 30 }); 31 32 test 33 .before(async (t) => { 34 // Create a bucket 35 await functions.setUpBucket(t, "bucketwritew"); 36 })("Bucket access is set to W", async (t) => { 37 await new Promise((resolve) => setTimeout(resolve, 2000)); 38 await t 39 .useRole(roles.bucketWrite) 40 .navigateTo("http://localhost:9090/buckets") 41 .expect( 42 Selector(`#access-${constants.TEST_BUCKET_NAME}-bucketwritew`) 43 .innerText, 44 ) 45 .eql("Access: W"); 46 }) 47 .after(async (t) => { 48 // Cleanup created bucket and corresponding uploads 49 await functions.cleanUpBucketAndUploads(t, "bucketwritew"); 50 }); 51 52 test 53 .before(async (t) => { 54 // Create a bucket 55 await functions.setUpBucket(t, "bucketwrite2"); 56 })("Upload button exists", async (t) => { 57 const uploadExists = elements.uploadButton.exists; 58 const testBucketBrowseButton = testBucketBrowseButtonFor("bucketwrite2"); 59 await t 60 .useRole(roles.bucketWrite) 61 .navigateTo("http://localhost:9090/browser") 62 .click(testBucketBrowseButton) 63 .expect(uploadExists) 64 .ok(); 65 }) 66 .after(async (t) => { 67 // Cleanup created bucket and corresponding uploads 68 await functions.cleanUpBucketAndUploads(t, "bucketwrite2"); 69 }); 70 71 test 72 .before(async (t) => { 73 // Create a bucket 74 await functions.setUpBucket(t, "bucketwrite3"); 75 })("Object can be uploaded to a bucket", async (t) => { 76 const testBucketBrowseButton = testBucketBrowseButtonFor("bucketwrite3"); 77 await t 78 .useRole(roles.bucketWrite) 79 .navigateTo("http://localhost:9090/browser") 80 .click(testBucketBrowseButton) 81 // Upload object to bucket 82 .setFilesToUpload(elements.uploadInput, "../uploads/test.txt"); 83 }) 84 .after(async (t) => { 85 // Cleanup created bucket and corresponding uploads 86 await functions.cleanUpBucketAndUploads(t, "bucketwrite3"); 87 }); 88 89 test 90 .before(async (t) => { 91 // Create a bucket 92 await functions.setUpBucket(t, "bucketwrite4"); 93 })("Object list table is disabled", async (t) => { 94 await t 95 .useRole(roles.bucketWrite) 96 .navigateTo("http://localhost:9090/browser") 97 .click(testBucketBrowseButtonFor("bucketwrite4")) 98 .expect(elements.bucketsTableDisabled.exists) 99 .ok(); 100 }) 101 .after(async (t) => { 102 // Cleanup created bucket and corresponding uploads 103 await functions.cleanUpBucketAndUploads(t, "bucketwrite4"); 104 });