Skip to content

Commit a8e6ec3

Browse files
abailly-akamaibnussman-akamai
authored andcommitted
staging hotfix: [UIE-9167] - IAM: Ensure proper permission mapping for view_account_settings (#12840)
* Ensure proper permission mapping for view_account_settings * revert unecessary e2e alterations
1 parent 5f8ee20 commit a8e6ec3

File tree

3 files changed

+67
-9
lines changed

3 files changed

+67
-9
lines changed

packages/manager/cypress/e2e/core/account/account-cancellation.spec.ts

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,51 @@ describe('Account cancellation', () => {
178178
mockGetAccount(mockAccount).as('getAccount');
179179
mockGetProfile(mockProfile).as('getProfile');
180180
mockGetProfileGrants(mockGrants).as('getGrants');
181+
mockCancelAccountError('Unauthorized', 403).as('cancelAccount');
182+
183+
// Navigate to Account Settings page, click "Close Account" button.
181184

182185
cy.visitWithLogin('/account/settings');
183186
cy.wait(['@getAccount', '@getProfile', '@getGrants']);
184187

185-
cy.findByText(
186-
"You don't have permissions to edit this Account. Please contact your account administrator to request the necessary permissions.",
187-
{ exact: false }
188-
).should('be.visible');
188+
cy.findByTestId('close-account')
189+
.should('be.visible')
190+
.within(() => {
191+
cy.findByTestId('close-account-button')
192+
.should('be.visible')
193+
.should('be.enabled')
194+
.click();
195+
});
196+
197+
// Fill out cancellation dialog and attempt submission.
198+
ui.dialog
199+
.findByTitle(cancellationDialogTitle)
200+
.should('be.visible')
201+
.within(() => {
202+
// Check both boxes but verify submit remains disabled without email
203+
cy.get('[data-qa-checkbox="deleteAccountServices"]').click();
204+
cy.get('[data-qa-checkbox="deleteAccountUsers"]').click();
205+
206+
ui.button
207+
.findByTitle('Close Account')
208+
.should('be.visible')
209+
.should('be.disabled');
210+
211+
cy.findByLabelText(`Enter your email address (${mockProfile.email})`)
212+
.should('be.visible')
213+
.should('be.enabled')
214+
.type(mockProfile.email);
215+
216+
ui.button
217+
.findByTitle('Close Account')
218+
.should('be.visible')
219+
.should('be.enabled')
220+
.click();
221+
222+
// Confirm that API unauthorized error message is displayed.
223+
cy.wait('@cancelAccount');
224+
cy.findByText('Unauthorized').should('be.visible');
225+
});
189226
});
190227
});
191228

packages/manager/cypress/e2e/core/account/account-linode-managed.spec.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,31 @@ describe('Account Linode Managed', () => {
120120
visitUrlWithManagedDisabled('/account/settings');
121121
cy.wait(['@getAccount', '@getProfile', '@getGrants']);
122122

123-
cy.findByText(
124-
"You don't have permissions to edit this Account. Please contact your account administrator to request the necessary permissions.",
125-
{ exact: false }
126-
).should('be.visible');
123+
ui.button
124+
.findByTitle('Add Linode Managed')
125+
.should('be.visible')
126+
.should('be.enabled')
127+
.click();
128+
129+
ui.dialog
130+
.findByTitle('Just to confirm...')
131+
.should('be.visible')
132+
.within(() => {
133+
cy.get('h6')
134+
.invoke('text')
135+
.then((text) => {
136+
expect(text.trim()).to.equal(linodeEnabledMessageText(0));
137+
});
138+
// Confirm that submit button is enabled.
139+
ui.button
140+
.findByTitle('Add Linode Managed')
141+
.should('be.visible')
142+
.should('be.enabled')
143+
.click();
144+
cy.wait('@enableLinodeManaged');
145+
// Confirm that Cloud Manager displays a notice about Linode managed is unauthorized.
146+
cy.findByText(errorMessage, { exact: false }).should('be.visible');
147+
});
127148
});
128149

129150
/*

packages/manager/src/features/IAM/hooks/adapters/accountGrantsToPermissions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const accountGrantsToPermissions = (
4242
list_user_grants: unrestricted, // TODO: verify mapping as this is not in the API
4343
view_account: unrestricted,
4444
view_account_login: unrestricted,
45-
view_account_settings: unrestricted,
45+
view_account_settings: hasReadAccess,
4646
view_enrolled_beta_program: unrestricted,
4747
view_network_usage: unrestricted,
4848
view_region_available_service: unrestricted,

0 commit comments

Comments
 (0)