Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mjac0bs committed Oct 3, 2023
1 parent ae8cf08 commit 499247b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/api-v4/src/aglb/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ type CertificateType = 'ca' | 'downstream';
export interface Certificate {
id: number;
label: string;
certificate: string;
type: CertificateType;
}

Expand Down
9 changes: 5 additions & 4 deletions packages/manager/src/factories/aglb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@linode/api-v4/lib/aglb/types';
import * as Factory from 'factory.ts';

const certificate = `
export const mockCertificate = `
-----BEGIN CERTIFICATE-----
MIID0DCCArigAwIBAgIBATANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJGUjET
MBEGA1UECAwKU29tZS1TdGF0ZTEOMAwGA1UEBwwFUGFyaXMxDTALBgNVBAoMBERp
Expand All @@ -39,7 +39,7 @@ cbTV5RDkrlaYwm5yqlTIglvCv7o=
-----END CERTIFICATE-----
`;

const key = `
const mockKey = `
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAvpnaPKLIKdvx98KW68lz8pGaRRcYersNGqPjpifMVjjE8LuC
oXgPU0HePnNTUjpShBnynKCvrtWhN+haKbSp+QWXSxiTrW99HBfAl1MDQyWcukoE
Expand Down Expand Up @@ -275,15 +275,16 @@ export const createServiceTargetFactory = Factory.Sync.makeFactory<ServiceTarget
// Certificate endpoints
// *********************
export const certificateFactory = Factory.Sync.makeFactory<Certificate>({
certificate: mockCertificate,
id: Factory.each((i) => i),
label: Factory.each((i) => `certificate-${i}`),
type: 'ca',
});

export const createCertificateFactory = Factory.Sync.makeFactory<CreateCertificatePayload>(
{
certificate,
key,
certificate: mockCertificate,
key: mockKey,
label: 'my-cert',
type: 'downstream',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Typography } from 'src/components/Typography';
import { useLoadBalancerCertificateCreateMutation } from 'src/queries/aglb/certificates';
import { getErrorMap } from 'src/utilities/errorUtils';

import { labelMap } from './EditCertificateDrawer';

import type { Certificate, CreateCertificatePayload } from '@linode/api-v4';

interface Props {
Expand Down Expand Up @@ -91,7 +93,7 @@ export const CreateCertificateDrawer = (props: Props) => {
/>
<TextField
errorText={errorMap.certificate}
label="TLS Certificate"
label={labelMap[type]}
labelTooltipText="TODO"
multiline
name="certificate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ import { act, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';

import { mockCertificate } from 'src/factories';
import { renderWithTheme } from 'src/utilities/testHelpers';

import { EditCertificateDrawer } from './EditCertificateDrawer';

const mockTLSCertificate: Certificate = {
certificate: mockCertificate,
id: 0,
label: 'test-tls-cert',
type: 'downstream',
};
const mockCACertificate: Certificate = {
certificate: mockCertificate,
id: 0,
label: 'test-ca-cert',
type: 'ca',
Expand All @@ -22,7 +25,7 @@ describe('EditCertificateDrawer', () => {
it('should contain the name of the cert in the drawer title and label field', () => {
const onClose = jest.fn();

const { getByTestId, getByLabelText } = renderWithTheme(
const { getByLabelText, getByTestId } = renderWithTheme(
<EditCertificateDrawer
certificate={mockTLSCertificate}
loadbalancerId={0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface Props {
open: boolean;
}

const labelMap: Record<Certificate['type'], string> = {
export const labelMap: Record<Certificate['type'], string> = {
ca: 'Server Certificate',
downstream: 'TLS Certificate',
};
Expand Down Expand Up @@ -92,23 +92,27 @@ export const EditCertificateDrawer = (props: Props) => {
value={formik.values.label}
/>
<TextField
disabled
errorText={errorMap.certificate}
label={labelMap[certificate.type]}
labelTooltipText="TODO: AGLB"
multiline
name="certificate"
onChange={formik.handleChange}
placeholder={certificate.certificate ?? ''}
trimmed
value={formik.values.certificate}
/>
{certificate?.type === 'downstream' && (
<TextField
disabled
errorText={errorMap.key}
label="Private Key"
labelTooltipText="TODO: AGLB"
multiline
name="key"
onChange={formik.handleChange}
placeholder="Key is concealed."
trimmed
value={formik.values.key}
/>
Expand Down

0 comments on commit 499247b

Please sign in to comment.