github.com/minio/console@v1.4.1/web-app/e2e/policies.spec.ts (about)

     1  // This file is part of MinIO Console Server
     2  // Copyright (c) 2023 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  import { expect } from "@playwright/test";
    17  import { generateUUID, test } from "./fixtures/baseFixture";
    18  import { minioadminFile } from "./consts";
    19  import { BUCKET_LIST_PAGE } from "./consts";
    20  
    21  test.use({ storageState: minioadminFile });
    22  
    23  test.beforeEach(async ({ page }) => {
    24    await page.goto(BUCKET_LIST_PAGE);
    25  });
    26  
    27  test("Can create a policy", async ({ page }) => {
    28    await page.getByRole("button", { name: "Policies" }).click();
    29    await page.getByRole("button", { name: "Create Policy" }).click();
    30    await page.getByLabel("Policy Name").click();
    31  
    32    const policyName = `policy-${generateUUID()}`;
    33  
    34    await page.getByLabel("Policy Name").fill(policyName);
    35    await page.locator("#code_wrapper").click();
    36    await page.locator("#code_wrapper").click();
    37    await page.locator("#code_wrapper").click();
    38    await page.locator("#code_wrapper").press("Meta+a");
    39    await page
    40      .locator("#code_wrapper")
    41      .fill(
    42        '{\n  "Version": "2012-10-17",\n  "Statement": [\n    {\n      "Effect": "Allow",\n      "Action": [\n        "s3:*"\n      ],\n      "Resource": [\n        "arn:aws:s3:::bucket1/*",\n        "arn:aws:s3:::bucket2/*",\n        "arn:aws:s3:::bucket3/*",\n        "arn:aws:s3:::bucket4/*"\n      ]\n    },\n    {\n      "Effect": "Deny",\n      "Action": [\n        "s3:DeleteBucket"\n      ],\n      "Resource": [\n        "arn:aws:s3:::*"\n      ]\n    }\n  ]\n}\n',
    43      );
    44    await page.getByRole("button", { name: "Save" }).click();
    45    await expect(page.getByRole("gridcell", { name: policyName })).toBeTruthy();
    46  });