Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: [M3-7511, M3-9147] restricted user has disabled inputs on object storage creation #11560

Merged
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11560-tests-1737658018185.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

tests of object storage creation form for restricted user ([#11560](https://github.com/linode/manager/pull/11560))
dmcintyr-akamai marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { mockGetAccount } from 'support/intercepts/account';
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
import { mockGetProfile } from 'support/intercepts/profile';
import { mockGetAccessKeys } from 'support/intercepts/object-storage';
import { accountFactory, objectStorageKeyFactory } from 'src/factories';
import { profileFactory } from 'src/factories/profile';
import { ui } from 'support/ui';

describe('Object Storage gen2 access keys tests', () => {
Expand Down Expand Up @@ -85,3 +87,55 @@ describe('Object Storage gen2 access keys tests', () => {
});
});
});

/**
* When a restricted user navigates to object-storage/access-keys/create, an error is shown in the "Create Access Key" drawer noting that the user does not have access key creation permissions
*/
describe('Object Storage Gen2 create access key modal has disabled fields for restricted user', () => {
beforeEach(() => {
mockAppendFeatureFlags({
objMultiCluster: true,
objectStorageGen2: { enabled: true },
}).as('getFeatureFlags');
mockGetAccount(
accountFactory.build({
capabilities: [
'Object Storage',
'Object Storage Endpoint Types',
'Object Storage Access Key Regions',
],
})
).as('getAccount');
// restricted user
mockGetProfile(
profileFactory.build({
email: 'mock-user@linode.com',
restricted: true,
})
).as('getProfile');
});

// access keys creation
it('create access keys form', () => {
cy.visitWithLogin('/object-storage/access-keys/create');

cy.wait(['@getFeatureFlags', '@getAccount', '@getProfile']);
// error message
ui.drawer
.findByTitle('Create Access Key')
.should('be.visible')
.within(() => {
cy.findByText(
/You don't have bucket_access to create an Access Key./
).should('be.visible');
// label
cy.findByLabelText(/Label.*/)
.should('be.visible')
.should('be.disabled');
// region
ui.regionSelect.find().should('be.visible').should('be.disabled');
// submit button is disabled
cy.findByTestId('submit').should('be.visible').should('be.disabled');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
mockGetBucketAccess,
mockCreateBucketError,
} from 'support/intercepts/object-storage';
import { mockGetProfile } from 'support/intercepts/profile';
import { mockGetRegions } from 'support/intercepts/regions';
import { ui } from 'support/ui';
import { checkRateLimitsTable } from 'support/util/object-storage-gen2';
Expand All @@ -18,6 +19,7 @@ import {
objectStorageEndpointsFactory,
regionFactory,
} from 'src/factories';
import { profileFactory } from 'src/factories/profile';
import { chooseRegion } from 'support/util/regions';
import type { ACLType, ObjectStorageEndpoint } from '@linode/api-v4';

Expand Down Expand Up @@ -716,3 +718,55 @@ describe('Object Storage Gen2 create bucket tests', () => {
});
});
});

/**
* When a restricted user navigates to object-storage/buckets/create, an error is shown in the "Create Bucket" drawer noting that the user does not have bucket creation permissions
*/
describe('Object Storage Gen2 create bucket modal has disabled fields for restricted user', () => {
beforeEach(() => {
mockAppendFeatureFlags({
objMultiCluster: true,
objectStorageGen2: { enabled: true },
}).as('getFeatureFlags');
mockGetAccount(
accountFactory.build({
capabilities: [
'Object Storage',
'Object Storage Endpoint Types',
'Object Storage Access Key Regions',
],
})
).as('getAccount');
// restricted user
mockGetProfile(
profileFactory.build({
email: 'mock-user@linode.com',
restricted: true,
})
).as('getProfile');
});

// bucket creation
it('create bucket form', () => {
cy.visitWithLogin('/object-storage/buckets/create');
cy.wait(['@getFeatureFlags', '@getAccount', '@getProfile']);

// error message
ui.drawer
.findByTitle('Create Bucket')
.should('be.visible')
.within(() => {
cy.findByText(/You don't have permissions to create a Bucket./).should(
'be.visible'
);
cy.findByLabelText(/Label.*/)
.should('be.visible')
.should('be.disabled');
ui.regionSelect.find().should('be.visible').should('be.disabled');
// submit button should be enabled
cy.findByTestId('create-bucket-button')
.should('be.visible')
.should('be.enabled');
});
});
});