110 lines
4.0 KiB
JavaScript
110 lines
4.0 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
/* eslint-disable no-undef */
|
|
const { expect } = require('@playwright/test');
|
|
const { nanoid } = require('nanoid');
|
|
|
|
const BaseResourcePage = require('./base-resource');
|
|
|
|
class StorageBucketsPage extends BaseResourcePage {
|
|
/**
|
|
* Creates a new AWS Storage Bucket.
|
|
* @param {string} scope Scope of the Storage Bucket
|
|
* @param {string} bucketName Name of the Storage Bucket
|
|
* @param {string} region Region of the Storage Bucket
|
|
* @param {string} accessKeyId Access Key ID for the Storage Bucket
|
|
* @param {string} secretAccessKey Secret Access Key for the Storage Bucket
|
|
* @param {string} workerFilter Worker filter for the Storage Bucket
|
|
* @returns Name of the Storage Bucket
|
|
*/
|
|
async createStorageBucketAws(
|
|
scope,
|
|
bucketName,
|
|
region,
|
|
accessKeyId,
|
|
secretAccessKey,
|
|
workerFilter,
|
|
) {
|
|
const storageBucketName = 'Bucket ' + nanoid();
|
|
await this.page
|
|
.getByRole('link', { name: 'Storage Buckets', exact: true })
|
|
.click();
|
|
await this.page.getByRole('link', { name: 'New Storage Bucket' }).click();
|
|
await this.page.getByLabel(new RegExp('Name*')).fill(storageBucketName);
|
|
await this.page.getByLabel('Scope').selectOption({ label: scope });
|
|
await this.page
|
|
.getByRole('group', { name: 'Provider' })
|
|
.getByLabel('Amazon S3')
|
|
.click();
|
|
await this.page.getByLabel('Bucket name').fill(bucketName);
|
|
await this.page.getByLabel('Region').fill(region);
|
|
await this.page.getByLabel('Access key ID').fill(accessKeyId);
|
|
await this.page.getByLabel('Secret access key').fill(secretAccessKey);
|
|
await this.page.getByLabel('Worker filter').fill(workerFilter);
|
|
await this.page.getByLabel('Disable credential rotation').click();
|
|
await this.page.getByRole('button', { name: 'Save' }).click();
|
|
await this.dismissSuccessAlert();
|
|
await expect(
|
|
this.page
|
|
.getByRole('navigation', { name: 'breadcrumbs' })
|
|
.getByText(storageBucketName),
|
|
).toBeVisible();
|
|
|
|
return storageBucketName;
|
|
}
|
|
|
|
/**
|
|
* Creates a new MinIO Storage Bucket.
|
|
* @param {string} scope Scope of the Storage Bucket
|
|
* @param {string} endpointUrl Endpoint URL of the Storage Bucket
|
|
* @param {string} bucketName Name of the Storage Bucket
|
|
* @param {string} region Region of the Storage Bucket
|
|
* @param {string} accessKeyId Access Key ID for the Storage Bucket
|
|
* @param {string} secretAccessKey Secret Access Key for the Storage Bucket
|
|
* @param {string} workerFilter Worker filter for the Storage Bucket
|
|
* @returns Name of the Storage Bucket
|
|
*/
|
|
async createStorageBucketMinio(
|
|
scope,
|
|
endpointUrl,
|
|
bucketName,
|
|
region,
|
|
accessKeyId,
|
|
secretAccessKey,
|
|
workerFilter,
|
|
) {
|
|
const storageBucketName = 'Bucket ' + nanoid();
|
|
await this.page
|
|
.getByRole('link', { name: 'Storage Buckets', exact: true })
|
|
.click();
|
|
await this.page.getByRole('link', { name: 'New Storage Bucket' }).click();
|
|
await this.page.getByLabel(new RegExp('Name*')).fill(storageBucketName);
|
|
await this.page.getByLabel('Scope').selectOption({ label: scope });
|
|
await this.page
|
|
.getByRole('group', { name: 'Provider' })
|
|
.getByLabel('MinIO')
|
|
.click();
|
|
await this.page.getByLabel('Endpoint URL').fill(endpointUrl);
|
|
await this.page.getByLabel('Bucket name').fill(bucketName);
|
|
await this.page.getByLabel('Region').fill(region);
|
|
await this.page.getByLabel('Access key ID').fill(accessKeyId);
|
|
await this.page.getByLabel('Secret access key').fill(secretAccessKey);
|
|
await this.page.getByLabel('Worker filter').fill(workerFilter);
|
|
await this.page.getByLabel('Disable credential rotation').click();
|
|
await this.page.getByRole('button', { name: 'Save' }).click();
|
|
await this.dismissSuccessAlert();
|
|
await expect(
|
|
this.page
|
|
.getByRole('navigation', { name: 'breadcrumbs' })
|
|
.getByText(storageBucketName),
|
|
).toBeVisible();
|
|
|
|
return storageBucketName;
|
|
}
|
|
}
|
|
|
|
module.exports = StorageBucketsPage;
|