-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,075 additions
and
1,159 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// This file is part of MinIO Console Server | ||
// Copyright (c) 2023 MinIO, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
import { test as setup } from "@playwright/test"; | ||
import { minioadminFile } from "./consts"; | ||
|
||
setup("authenticate as admin", async ({ page }) => { | ||
// Perform authentication steps. Replace these actions with your own. | ||
await page.goto("http://localhost:5005"); | ||
await page.getByPlaceholder("Username").click(); | ||
await page.getByPlaceholder("Username").fill("minioadmin"); | ||
await page.getByPlaceholder("Password").click(); | ||
await page.getByPlaceholder("Password").fill("minioadmin"); | ||
await page.getByRole("button", { name: "Login" }).click(); | ||
|
||
// we need to give the browser time to store the cookies | ||
await page.waitForTimeout(1000); | ||
// End of authentication steps. | ||
|
||
await page.context().storageState({ path: minioadminFile }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// This file is part of MinIO Console Server | ||
// Copyright (c) 2023 MinIO, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
import { expect } from "@playwright/test"; | ||
import { generateUUID, test } from "./fixtures/baseFixture"; | ||
import { minioadminFile } from "./consts"; | ||
|
||
test.use({ storageState: minioadminFile }); | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto("http://localhost:5005/"); | ||
}); | ||
|
||
test("create a new bucket", async ({ page }) => { | ||
await page.getByRole("link", { name: "Buckets Buckets" }).click(); | ||
await page.getByRole("button", { name: "Create Bucket" }).click(); | ||
await page.getByLabel("Bucket Name*").click(); | ||
|
||
const bucketName = `new-bucket-${generateUUID()}`; | ||
|
||
await page.getByLabel("Bucket Name*").fill(bucketName); | ||
await page.getByRole("button", { name: "Create Bucket" }).click(); | ||
await expect(page.locator(`#manageBucket-${bucketName}`)).toBeTruthy(); | ||
}); | ||
|
||
test("invalid bucket name", async ({ page }) => { | ||
await page.getByRole("link", { name: "Buckets Buckets" }).click(); | ||
await page.getByRole("button", { name: "Create Bucket" }).click(); | ||
await page.getByLabel("Bucket Name*").click(); | ||
await page.getByLabel("Bucket Name*").fill("invalid name"); | ||
await page.getByRole("button", { name: "View Bucket Naming Rules" }).click(); | ||
await expect( | ||
page.getByText( | ||
"Bucket names can consist only of lowercase letters, numbers, dots (.), and hyphe" | ||
) | ||
).toBeTruthy(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This file is part of MinIO Console Server | ||
// Copyright (c) 2023 MinIO, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
export const minioadminFile = "playwright/.auth/admin.json"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// This file is part of MinIO Console Server | ||
// Copyright (c) 2023 MinIO, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import * as crypto from "crypto"; | ||
import { test as baseTest } from "@playwright/test"; | ||
|
||
const istanbulCLIOutput = path.join(process.cwd(), ".nyc_output"); | ||
|
||
export function generateUUID(): string { | ||
return crypto.randomBytes(16).toString("hex"); | ||
} | ||
|
||
export const test = baseTest.extend({ | ||
context: async ({ context }, use) => { | ||
await context.addInitScript(() => | ||
window.addEventListener("beforeunload", () => | ||
(window as any).collectIstanbulCoverage( | ||
JSON.stringify((window as any).__coverage__) | ||
) | ||
) | ||
); | ||
await fs.promises.mkdir(istanbulCLIOutput, { recursive: true }); | ||
await context.exposeFunction( | ||
"collectIstanbulCoverage", | ||
(coverageJSON: string) => { | ||
if (coverageJSON) | ||
fs.writeFileSync( | ||
path.join( | ||
istanbulCLIOutput, | ||
`playwright_coverage_${generateUUID()}.json` | ||
), | ||
coverageJSON | ||
); | ||
} | ||
); | ||
await use(context); | ||
for (const page of context.pages()) { | ||
await page.evaluate(() => | ||
(window as any).collectIstanbulCoverage( | ||
JSON.stringify((window as any).__coverage__) | ||
) | ||
); | ||
} | ||
}, | ||
}); | ||
|
||
export const expect = test.expect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// This file is part of MinIO Console Server | ||
// Copyright (c) 2023 MinIO, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import { expect } from "@playwright/test"; | ||
import { generateUUID, test } from "./fixtures/baseFixture"; | ||
import { minioadminFile } from "./consts"; | ||
|
||
test.use({ storageState: minioadminFile }); | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto("http://localhost:5005/"); | ||
}); | ||
|
||
test("Add a new group", async ({ page }) => { | ||
await page.getByRole("button", { name: "Identity Identity" }).click(); | ||
await page.getByRole("link", { name: "Groups Groups" }).click(); | ||
await page.getByRole("button", { name: "Create Group" }).click(); | ||
|
||
const groupName = `new-group-${generateUUID()}`; | ||
|
||
await page.getByLabel("Group Name").fill(groupName); | ||
await page.getByRole("button", { name: "Save" }).click(); | ||
await expect(page.getByRole("gridcell", { name: groupName })).toBeTruthy(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test("Basic `minioadmin` Login", async ({ page, context }) => { | ||
await page.goto("http://localhost:5005"); | ||
await page.getByPlaceholder("Username").click(); | ||
await page.getByPlaceholder("Username").fill("minioadmin"); | ||
await page.getByPlaceholder("Password").click(); | ||
await page.getByPlaceholder("Password").fill("minioadmin"); | ||
await page.getByRole("button", { name: "Login" }).click(); | ||
await context.storageState({ path: "storage/minioadmin.json" }); | ||
await expect(page.getByRole("main").getByText("Object Browser")).toBeTruthy(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// This file is part of MinIO Console Server | ||
// Copyright (c) 2023 MinIO, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
import { expect } from "@playwright/test"; | ||
import { generateUUID, test } from "./fixtures/baseFixture"; | ||
import { minioadminFile } from "./consts"; | ||
|
||
test.use({ storageState: minioadminFile }); | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto("http://localhost:5005/"); | ||
}); | ||
|
||
test("Can create a policy", async ({ page }) => { | ||
await page.getByRole("link", { name: "Policies Policies" }).click(); | ||
await page.getByRole("button", { name: "Create Policy" }).click(); | ||
await page.getByLabel("Policy Name").click(); | ||
|
||
const policyName = `policy-${generateUUID()}`; | ||
|
||
await page.getByLabel("Policy Name").fill(policyName); | ||
await page.locator("#code_wrapper").click(); | ||
await page.locator("#code_wrapper").click(); | ||
await page.locator("#code_wrapper").click(); | ||
await page.locator("#code_wrapper").press("Meta+a"); | ||
await page | ||
.locator("#code_wrapper") | ||
.fill( | ||
'{\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' | ||
); | ||
await page.getByRole("button", { name: "Save" }).click(); | ||
await expect(page.getByRole("gridcell", { name: policyName })).toBeTruthy(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.