github.com/minio/console@v1.4.1/web-app/tests/permissions-3/bucketAssignPolicy.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  
    20  import * as functions from "../utils/functions";
    21  import { bucketsElement, logoutItem } from "../utils/elements-menu";
    22  import { Selector } from "testcafe";
    23  import * as constants from "../utils/constants";
    24  import { manageButtonFor } from "../utils/functions";
    25  
    26  fixture("For user with Bucket Assign Policy permissions")
    27    .page("http://localhost:9090")
    28    .beforeEach(async (t) => {
    29      await t.useRole(roles.bucketAssignPolicy);
    30    });
    31  
    32  // Bucket assign policy permissions
    33  test("Buckets sidebar item exists", async (t) => {
    34    const bucketsExist = bucketsElement.exists;
    35    await t.expect(bucketsExist).ok();
    36  });
    37  
    38  test
    39    .before(async (t) => {
    40      // Create a bucket
    41      await functions.setUpBucket(t, "bucketassign1");
    42    })("A readonly policy can be assigned to a bucket", async (t) => {
    43      await t
    44        // We need to log back in after we use the admin account to create bucket,
    45        // using the specific role we use in this module
    46        .useRole(roles.bucketAssignPolicy)
    47        .navigateTo("http://localhost:9090/buckets")
    48        .click(manageButtonFor("bucketassign1"))
    49        .click(elements.bucketAccessRulesTab)
    50        .click(elements.addAccessRuleButton)
    51        .typeText(elements.bucketsPrefixInput, "readonlytest")
    52        .click(elements.bucketsAccessInput)
    53        .click(elements.bucketsAccessReadOnlyInput)
    54        .click(elements.saveButton);
    55    })
    56    .after(async (t) => {
    57      // Cleanup created bucket
    58      await functions.cleanUpBucket(t, "bucketassign1");
    59    });
    60  
    61  test
    62    .before(async (t) => {
    63      // Create a bucket
    64      await functions.setUpBucket(t, "bucketassign3");
    65    })("A writeonly policy can be assigned to a bucket", async (t) => {
    66      await t
    67        // We need to log back in after we use the admin account to create bucket,
    68        // using the specific role we use in this module
    69        .useRole(roles.bucketAssignPolicy)
    70        .navigateTo("http://localhost:9090/buckets")
    71        .click(manageButtonFor("bucketassign3"))
    72        .click(elements.bucketAccessRulesTab)
    73        .click(elements.addAccessRuleButton)
    74        .typeText(elements.bucketsPrefixInput, "writeonlytest")
    75        .click(elements.bucketsAccessInput)
    76        .click(elements.bucketsAccessWriteOnlyInput)
    77        .click(elements.saveButton);
    78    })
    79    .after(async (t) => {
    80      // Cleanup created bucket
    81      await functions.cleanUpBucket(t, "bucketassign3");
    82    });
    83  
    84  test
    85    .before(async (t) => {
    86      // Create a bucket
    87      await functions.setUpBucket(t, "bucketassign4");
    88    })("A readwrite policy can be assigned to a bucket", async (t) => {
    89      await t
    90        // We need to log back in after we use the admin account to create bucket,
    91        // using the specific role we use in this module
    92        .useRole(roles.bucketAssignPolicy)
    93        .navigateTo("http://localhost:9090/buckets")
    94        .click(manageButtonFor("bucketassign4"))
    95        .click(elements.bucketAccessRulesTab)
    96        .click(elements.addAccessRuleButton)
    97        .typeText(elements.bucketsPrefixInput, "readwritetest")
    98        .click(elements.bucketsAccessInput)
    99        .click(elements.bucketsAccessReadWriteInput)
   100        .click(elements.saveButton);
   101    })
   102    .after(async (t) => {
   103      // Cleanup created bucket
   104      await functions.cleanUpBucket(t, "bucketassign4");
   105    });
   106  
   107  // test
   108  //   .before(async (t) => {
   109  //     // Create a bucket
   110  //     await functions.setUpBucket(t, "bucketassign5");
   111  //   })("Previously assigned policy to a bucket can be deleted", async (t) => {
   112  //     await new Promise((resolve) => setTimeout(resolve, 2000));
   113  //     await t
   114  //       .useRole(roles.bucketAssignPolicy)
   115  //       .navigateTo("http://localhost:9090/buckets")
   116  //       .click(manageButtonFor("bucketassign5"))
   117  //       .click(elements.bucketAccessRulesTab)
   118  //       .click(elements.deleteIconButtonAlt)
   119  //       .click(elements.deleteButton)
   120  //       .click(logoutItem);
   121  //   })
   122  //   .after(async (t) => {
   123  //     // Cleanup created bucket
   124  //     await functions.cleanUpBucket(t, "bucketassign5");
   125  //   });