github.com/minio/console@v1.4.1/web-app/tests/permissions-B/bucketWritePrefixOnly.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 { Selector } from "testcafe";
    20  
    21  fixture("For user with Bucket Write to specific prefix permissions").page(
    22    "http://localhost:9090",
    23  );
    24  
    25  test
    26    .before(async (t) => {})(
    27      "Upload File button is disable and Upload Folder button is enabled on bucket root path",
    28      async (t) => {
    29        const uploadButton = elements.uploadButton;
    30        await t
    31          .useRole(roles.bucketWritePrefixOnly)
    32          .navigateTo("http://localhost:9090/browser/testcafe")
    33          .click(uploadButton)
    34          .expect(
    35            Selector("div")
    36              .withAttribute("label", "Upload File")
    37              .hasClass("disabled"),
    38          )
    39          .ok()
    40          .expect(
    41            Selector("div")
    42              .withAttribute("label", "Upload Folder")
    43              .hasClass("disabled"),
    44          )
    45          .notOk();
    46      },
    47    )
    48    .after(async (t) => {});
    49  
    50  test
    51    .before(async (t) => {})(
    52      "Upload File and Folder buttons are enabled on bucket prefix path",
    53      async (t) => {
    54        const uploadButton = elements.uploadButton;
    55        await t
    56          .useRole(roles.bucketWritePrefixOnly)
    57          .navigateTo("http://localhost:9090/browser/testcafe/d3JpdGU=")
    58          .click(uploadButton)
    59          .expect(
    60            Selector("div")
    61              .withAttribute("label", "Upload File")
    62              .hasClass("disabled"),
    63          )
    64          .notOk()
    65          .expect(
    66            Selector("div")
    67              .withAttribute("label", "Upload Folder")
    68              .hasClass("disabled"),
    69          )
    70          .notOk();
    71      },
    72    )
    73    .after(async (t) => {});