github.com/minio/console@v1.4.1/web-app/tests/permissions-2/deleteObjectWithPrefixOnly.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 { Selector } from "testcafe";
    19  import * as functions from "../utils/functions";
    20  import { testBucketBrowseButtonFor } from "../utils/functions";
    21  
    22  fixture("Delete Objects With Prefix Only policy").page(
    23    "http://localhost:9090/",
    24  );
    25  
    26  export const sideBar = Selector("#details-panel");
    27  export const sideBarDeleteButton = sideBar.find("button").withText("Delete");
    28  const bucket1 = "test-1";
    29  const test1BucketBrowseButton = testBucketBrowseButtonFor(bucket1);
    30  const bucket2 = "test-2";
    31  const test2BucketBrowseButton = testBucketBrowseButtonFor(bucket2);
    32  const bucket3 = "test-3";
    33  const test3BucketBrowseButton = testBucketBrowseButtonFor(bucket3);
    34  test
    35    .before(async (t) => {
    36      await functions.setUpBucket(t, bucket1);
    37      await functions.uploadObjectToBucket(
    38        t,
    39        bucket1,
    40        "test.txt",
    41        "web-app/tests/uploads/test.txt",
    42      );
    43    })("Delete button is disabled for object inside bucket", async (t) => {
    44      await t
    45        .useRole(roles.deleteObjectWithPrefixOnly)
    46        .navigateTo(`http://localhost:9090/browser`)
    47        .click(test1BucketBrowseButton)
    48        .click(
    49          Selector(".ReactVirtualized__Table__rowColumn").withText("test.txt"),
    50        )
    51        .expect(sideBarDeleteButton.hasAttribute("disabled"))
    52        .ok();
    53    })
    54    .after(async (t) => {
    55      await functions.cleanUpBucketAndUploads(t, bucket1);
    56    });
    57  
    58  test
    59    .before(async (t) => {
    60      await functions.setUpBucket(t, bucket2);
    61      await functions.uploadObjectToBucket(
    62        t,
    63        bucket2,
    64        "digitalinsights/xref_cust_guid_actd-v1.txt",
    65        "web-app/tests/uploads/test.txt",
    66      );
    67    })(
    68      "Delete button is enabled for object that matches prefix inside bucket",
    69      async (t) => {
    70        await t
    71          .useRole(roles.deleteObjectWithPrefixOnly)
    72          .navigateTo(`http://localhost:9090/browser`)
    73          .click(test2BucketBrowseButton)
    74          .click(
    75            Selector(".ReactVirtualized__Table__rowColumn").withText(
    76              "digitalinsights",
    77            ),
    78          )
    79          .click(
    80            Selector(".ReactVirtualized__Table__rowColumn").withText(
    81              "xref_cust_guid_actd-v1.txt",
    82            ),
    83          )
    84          .expect(sideBarDeleteButton.hasAttribute("disabled"))
    85          .notOk();
    86      },
    87    )
    88    .after(async (t) => {
    89      await functions.cleanUpBucketAndUploads(t, bucket2);
    90    });
    91  
    92  test
    93    .before(async (t) => {
    94      await functions.setUpBucket(t, bucket3);
    95      await functions.uploadObjectToBucket(
    96        t,
    97        bucket3,
    98        "digitalinsights/test.txt",
    99        "web-app/tests/uploads/test.txt",
   100      );
   101    })(
   102      "Delete button is disabled for object that doesn't matches prefix inside bucket",
   103      async (t) => {
   104        await t
   105          .useRole(roles.deleteObjectWithPrefixOnly)
   106          .navigateTo(`http://localhost:9090/browser`)
   107          .click(test3BucketBrowseButton)
   108          .click(
   109            Selector(".ReactVirtualized__Table__rowColumn").withText(
   110              "digitalinsights",
   111            ),
   112          )
   113          .click(
   114            Selector(".ReactVirtualized__Table__rowColumn").withText("test.txt"),
   115          )
   116          .expect(sideBarDeleteButton.hasAttribute("disabled"))
   117          .ok();
   118      },
   119    )
   120    .after(async (t) => {
   121      await functions.cleanUpBucketAndUploads(t, bucket3);
   122    });