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

feat: [M3-7160] - Add AGLB "Edit Certificate" drawer #9723

Merged
merged 15 commits into from
Oct 6, 2023

Conversation

mjac0bs
Copy link
Contributor

@mjac0bs mjac0bs commented Sep 26, 2023

Description 📝

Add an edit drawer for AGLB certificates.

Major Changes 🔄

  • Creates the Edit Certificate drawer with dynamic fields depending on certificate type
  • Adds the useLoadBalancerCertificateMutation
  • Adds a unit test for EditCertificateDrawer component
  • Updates the MSW PUT endpoint for */v4beta/aglb/:id/certificates/:certId to return a downstream cert in addition to the existing ca certs.

Preview 📷

Service Target Certificates TLS Certificates
Screenshot 2023-10-05 at 3 30 54 PM Screenshot 2023-10-05 at 3 30 38 PM

How to test 🧪

  1. How to setup test environment?
  • Check out this PR.
  • yarn dev
  • Ensure AGLB feature flag is on and MSW is enabled.
  1. How to verify changes?
  • Go to http://localhost:3000/loadbalancers/0/certificates/downstream.
  • Click on the Edit button in the action menu of the tls-certificate. Confirm that the edit drawer matches the mocks above for a TLS certificate.
  • Click on the Edit button in the action menu of any other certificate (they're all of type ca). Confirm that the edit drawer matches the mocks above for a Service Target certificate.
  • Confirm that a PUT request is sent by the MSW when the Update Certificate button is clicked.
  • Confirm that no PUT request is sent by the MSW when the drawer is Canceled or closed out of.
  • Confirm form validation:
    • If a user edits the label of either certificate type, the form submits without error.
    • If a user edits the certificate of a Service Target (ca) cert, the form submits without error.
    • If a user edits the certificate of a TLS (downstream) cert and submits without a key, they should receive a validation error upon submission indicating Private Key is required in that case.
  1. How to run Unit or E2E tests?
    Unit:
yarn test EditCertificateDrawer

E2E:
Will be completed in M3-7134, since there was an existing ticket created for this.

@mjac0bs mjac0bs added Work in Progress ACLB Relating to the Akamai Cloud Load Balancer labels Sep 26, 2023
@mjac0bs mjac0bs self-assigned this Sep 26, 2023
<TextField
errorText={errorMap.certificate}
label={labelMap[certificate.type]}
labelTooltipText="TODO: AGLB"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the plan is for the copy in these tooltips, but given that we are not able to retrieve or display a certificate object's certificate or key fields for security reasons, we should probably mention that in this form so that the user does not think that their cert/key data is missing.

@mjac0bs mjac0bs marked this pull request as ready for review September 27, 2023 20:41
@mjac0bs mjac0bs requested a review from a team as a code owner September 27, 2023 20:42
@mjac0bs mjac0bs requested review from cpathipa and cliu-akamai and removed request for a team September 27, 2023 20:42
Copy link
Member

@bnussman-akamai bnussman-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! My only concerns regard consistency between the Create Drawer and this new Edit Drawer. We may need to ask Daniel for some clarification.

  • In the Create Service Target Cert drawer we say "TLS Certificate" but in the edit drawer we say "Service Certificate". I guess we should say "Service Certificate" in both places?
  • We have placeholders in the Create drawer but not the edit drawer

@mjac0bs
Copy link
Contributor Author

mjac0bs commented Sep 29, 2023

@bnussman-akamai

  • In the Create Service Target Cert drawer we say "TLS Certificate" but in the edit drawer we say "Service Certificate". I guess we should say "Service Certificate" in both places?

Good catch on this! 🔍 Asked Daniel for clarification in a comment on the mocks and reached out to let him know.

  • We have placeholders in the Create drawer but not the edit drawer

Yeah, I'm not sure what's best here because we could use the same example placeholder as the Create drawer, but that might face the same problem as leaving it blank -- causing users to think that it is missing/incomplete, when really we're just not able to display the data. I also asked Daniel about this in the mocks.

@@ -91,7 +93,7 @@ export const CreateCertificateDrawer = (props: Props) => {
/>
<TextField
errorText={errorMap.certificate}
label="TLS Certificate"
label={labelMap[type]}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Create Service Target Cert drawer we say "TLS Certificate" but in the edit drawer we say "Service Certificate". I guess we should say "Service Certificate" in both places?

Daniel updated to mocks so that the Create drawer now labels the field as "Server Certificate" for ca/service target certificates and is "TLS Certificate" for downstream/TLS, so I made the change to dynamically render the label based on type in the Create drawer here.

@@ -13,7 +13,7 @@ import {
} from '@linode/api-v4/lib/aglb/types';
import * as Factory from 'factory.ts';

const certificate = `
export const mockCertificate = `
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I preemptively renamed in hope of making it clear that these are not real values that are a cause of security concern.

@@ -141,6 +141,7 @@ type CertificateType = 'ca' | 'downstream';
export interface Certificate {
id: number;
label: string;
certificate: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API spec has been updated to indicate that certificate will now be returned in GET /v4beta/aglb/{id}/certificates.

Copy link
Member

@bnussman-akamai bnussman-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we make the PUT, I think we may want to omit certificate and key from the body if they are unchanged. I worry this might make the API clear out the certificate and key if we send an empty string or perhaps cause a validation error.

Screenshot 2023-10-04 at 1 48 05 PM

Copy link
Member

@bnussman-akamai bnussman-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! 🎉

Copy link
Contributor

@cpathipa cpathipa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Over all looks great! left couple comments for minor suggestions.
Validated

  • Edit Certificate drawer with dynamic fields depending on certificate type
  • test coverage for EditCertificateDrawer

@mjac0bs
Copy link
Contributor Author

mjac0bs commented Oct 5, 2023

@bnussman-akamai , @cpathipa

Thanks for the reviews! I'll be merging this shortly. In my last commit, I addressed UX feedback to make the cert field contain the actual cert value instead of placeholder text. We now check whether the user is updating the cert from its original value and, if they are, require them to provide a key (as per the API spec). Otherwise, we can safely exclude the cert in the request and therefore avoid the user needing to submit their existing key, which we cannot return. (Validation seems to work correctly, as do request payloads; I think when I tried this initially, I was having unrelated validation issues.)

Creating follow up tickets to address additional UX feedback:

  • display the cert id in the table

@mjac0bs mjac0bs added Approved Multiple approvals and ready to merge! and removed Ready for Review labels Oct 5, 2023
@mjac0bs
Copy link
Contributor Author

mjac0bs commented Oct 6, 2023

One relevant e2e failure fixed due to the typo correction in the Create Cert drawer; this test now passes:
image

@mjac0bs mjac0bs merged commit 459f7e7 into linode:develop Oct 6, 2023
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ACLB Relating to the Akamai Cloud Load Balancer Approved Multiple approvals and ready to merge!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants