Skip to content

Commit

Permalink
change: [M3-9041] - Remove Images are not encrypted warning (#11443)
Browse files Browse the repository at this point in the history
* remove image encryption warning

* remove unit test

* add changeset

* update cypress test

---------

Co-authored-by: Banks Nussman <banks@nussman.us>
  • Loading branch information
bnussman-akamai and bnussman authored Dec 22, 2024
1 parent 2810a5f commit ab2943b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 213 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11443-removed-1734624899643.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Removed
---

`Images are not encrypted warning` warning ([#11443](https://github.com/linode/manager/pull/11443))
157 changes: 4 additions & 153 deletions packages/manager/cypress/e2e/core/images/create-image.spec.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,9 @@
import type { Linode, Region } from '@linode/api-v4';
import { accountFactory, linodeFactory, regionFactory } from 'src/factories';
import type { Linode } from '@linode/api-v4';
import { authenticate } from 'support/api/authentication';
import { mockGetAccount } from 'support/intercepts/account';
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
import { ui } from 'support/ui';
import { cleanUp } from 'support/util/cleanup';
import { createTestLinode } from 'support/util/linodes';
import { randomLabel, randomPhrase } from 'support/util/random';
import { mockGetRegions } from 'support/intercepts/regions';
import {
mockGetLinodeDetails,
mockGetLinodes,
} from 'support/intercepts/linodes';

const mockRegions: Region[] = [
regionFactory.build({
capabilities: ['Linodes', 'Disk Encryption'],
id: 'us-east',
label: 'Newark, NJ',
site_type: 'core',
}),
regionFactory.build({
capabilities: ['Linodes', 'Disk Encryption'],
id: 'us-den-1',
label: 'Distributed - Denver, CO',
site_type: 'distributed',
}),
];

const mockLinodes: Linode[] = [
linodeFactory.build({
label: 'core-region-linode',
region: mockRegions[0].id,
}),
linodeFactory.build({
label: 'distributed-region-linode',
region: mockRegions[1].id,
}),
];

const DISK_ENCRYPTION_IMAGES_CAVEAT_COPY =
'Virtual Machine Images are not encrypted.';

authenticate();
describe('create image (e2e)', () => {
Expand All @@ -53,9 +16,9 @@ describe('create image (e2e)', () => {
const label = randomLabel();
const description = randomPhrase();

// When Alpine 3.19 becomes deprecated, we will have to update these values for the test to pass.
const image = 'linode/alpine3.19';
const disk = 'Alpine 3.19 Disk';
// When Alpine 3.20 becomes deprecated, we will have to update these values for the test to pass.
const image = 'linode/alpine3.20';
const disk = 'Alpine 3.20 Disk';

cy.defer(
() => createTestLinode({ image }, { waitForDisks: true }),
Expand Down Expand Up @@ -123,116 +86,4 @@ describe('create image (e2e)', () => {
});
});
});

it('displays notice informing user that Images are not encrypted, provided the LDE feature is enabled and the selected linode is not in a distributed region', () => {
// Mock feature flag -- @TODO LDE: Remove feature flag once LDE is fully rolled out
mockAppendFeatureFlags({
linodeDiskEncryption: true,
}).as('getFeatureFlags');

// Mock responses
const mockAccount = accountFactory.build({
capabilities: ['Linodes', 'Disk Encryption'],
});

mockGetAccount(mockAccount).as('getAccount');
mockGetRegions(mockRegions).as('getRegions');
mockGetLinodes(mockLinodes).as('getLinodes');

// intercept request
cy.visitWithLogin('/images/create');
cy.wait(['@getFeatureFlags', '@getAccount', '@getLinodes', '@getRegions']);

// Find the Linode select and open it
cy.findByLabelText('Linode')
.should('be.visible')
.should('be.enabled')
.should('have.attr', 'placeholder', 'Select a Linode')
.click();

// Select the Linode
ui.autocompletePopper
.findByTitle(mockLinodes[0].label)
.should('be.visible')
.should('be.enabled')
.click();

// Check if notice is visible
cy.findByText(DISK_ENCRYPTION_IMAGES_CAVEAT_COPY).should('be.visible');
});

it('does not display a notice informing user that Images are not encrypted if the LDE feature is disabled', () => {
// Mock feature flag -- @TODO LDE: Remove feature flag once LDE is fully rolled out
mockAppendFeatureFlags({
linodeDiskEncryption: false,
}).as('getFeatureFlags');

// Mock responses
const mockAccount = accountFactory.build({
capabilities: ['Linodes', 'Disk Encryption'],
});

mockGetAccount(mockAccount).as('getAccount');
mockGetRegions(mockRegions).as('getRegions');
mockGetLinodes(mockLinodes).as('getLinodes');

// intercept request
cy.visitWithLogin('/images/create');
cy.wait(['@getFeatureFlags', '@getAccount', '@getLinodes', '@getRegions']);

// Find the Linode select and open it
cy.findByLabelText('Linode')
.should('be.visible')
.should('be.enabled')
.should('have.attr', 'placeholder', 'Select a Linode')
.click();

// Select the Linode
ui.autocompletePopper
.findByTitle(mockLinodes[0].label)
.should('be.visible')
.should('be.enabled')
.click();

// Check if notice is visible
cy.findByText(DISK_ENCRYPTION_IMAGES_CAVEAT_COPY).should('not.exist');
});

it('does not display a notice informing user that Images are not encrypted if the selected linode is in a distributed region', () => {
// Mock feature flag -- @TODO LDE: Remove feature flag once LDE is fully rolled out
mockAppendFeatureFlags({
linodeDiskEncryption: true,
}).as('getFeatureFlags');

// Mock responses
const mockAccount = accountFactory.build({
capabilities: ['Linodes', 'Disk Encryption'],
});

mockGetAccount(mockAccount).as('getAccount');
mockGetRegions(mockRegions).as('getRegions');
mockGetLinodes(mockLinodes).as('getLinodes');
mockGetLinodeDetails(mockLinodes[1].id, mockLinodes[1]);

// intercept request
cy.visitWithLogin('/images/create');
cy.wait(['@getFeatureFlags', '@getAccount', '@getRegions', '@getLinodes']);

// Find the Linode select and open it
cy.findByLabelText('Linode')
.should('be.visible')
.should('be.enabled')
.should('have.attr', 'placeholder', 'Select a Linode')
.click();

// Select the Linode
ui.autocompletePopper
.findByTitle(mockLinodes[1].label)
.should('be.visible')
.should('be.enabled')
.click();

// Check if notice is visible
cy.findByText(DISK_ENCRYPTION_IMAGES_CAVEAT_COPY).should('not.exist');
});
});
3 changes: 0 additions & 3 deletions packages/manager/src/components/Encryption/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ export const DISK_ENCRYPTION_DESCRIPTION_NODE_POOL_REBUILD_CAVEAT =
export const DISK_ENCRYPTION_BACKUPS_CAVEAT_COPY =
'Virtual Machine Backups are not encrypted.';

export const DISK_ENCRYPTION_IMAGES_CAVEAT_COPY =
'Virtual Machine Images are not encrypted.';

export const ENCRYPT_DISK_DISABLED_REBUILD_LKE_REASON =
'The Encrypt Disk setting cannot be changed for a Linode attached to a node pool.';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,38 +197,6 @@ describe('CreateImageTab', () => {
);
});

it('should render an encryption notice if disk encryption is enabled and the Linode is not in a distributed compute region', async () => {
const region = regionFactory.build({ site_type: 'core' });
const linode = linodeFactory.build({ region: region.id });

server.use(
http.get('*/v4/linode/instances', () => {
return HttpResponse.json(makeResourcePage([linode]));
}),
http.get('*/v4/linode/instances/:id', () => {
return HttpResponse.json(linode);
}),
http.get('*/v4/regions', () => {
return HttpResponse.json(makeResourcePage([region]));
})
);

const { findByText, getByLabelText } = renderWithTheme(<CreateImageTab />, {
flags: { linodeDiskEncryption: true },
});

const linodeSelect = getByLabelText('Linode');

await userEvent.click(linodeSelect);

const linodeOption = await findByText(linode.label);

await userEvent.click(linodeOption);

// Verify encryption notice renders
await findByText('Virtual Machine Images are not encrypted.');
});

it('should auto-populate image label based on linode and disk', async () => {
const linode = linodeFactory.build();
const disk1 = linodeDiskFactory.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ import {
} from '@linode/ui';
import { createImageSchema } from '@linode/validation';
import { useSnackbar } from 'notistack';
import * as React from 'react';
import React from 'react';
import { Controller, useForm } from 'react-hook-form';
import { useHistory, useLocation } from 'react-router-dom';

import { DISK_ENCRYPTION_IMAGES_CAVEAT_COPY } from 'src/components/Encryption/constants';
import { useIsDiskEncryptionFeatureEnabled } from 'src/components/Encryption/utils';
import { Link } from 'src/components/Link';
import { TagsInput } from 'src/components/TagsInput/TagsInput';
import { getRestrictedResourceText } from 'src/features/Account/utils';
Expand Down Expand Up @@ -78,10 +76,6 @@ export const CreateImageTab = () => {
globalGrantType: 'add_images',
});

const {
isDiskEncryptionFeatureEnabled,
} = useIsDiskEncryptionFeatureEnabled();

const onSubmit = handleSubmit(async (values) => {
try {
await createImage(values);
Expand Down Expand Up @@ -157,17 +151,6 @@ export const CreateImageTab = () => {
'Object Storage'
);

/*
We only want to display the notice about disk encryption if:
1. the Disk Encryption feature is enabled
2. a linode is selected
2. the selected linode is not in an Edge region
*/
const showDiskEncryptionWarning =
isDiskEncryptionFeatureEnabled &&
selectedLinodeId !== null &&
!linodeIsInDistributedRegion;

const linodeSelectHelperText = grants?.linode.some(
(grant) => grant.permissions === 'read_only'
)
Expand Down Expand Up @@ -259,13 +242,6 @@ export const CreateImageTab = () => {
regions.
</Notice>
)}
{showDiskEncryptionWarning && (
<Notice variant="warning">
<Typography sx={(theme) => ({ fontFamily: theme.font.normal })}>
{DISK_ENCRYPTION_IMAGES_CAVEAT_COPY}
</Typography>
</Notice>
)}
<Controller
render={({ field, fieldState }) => (
<Autocomplete
Expand Down

0 comments on commit ab2943b

Please sign in to comment.