Repository navigation
NAS-144563 / 28.0.0-BETA.1 / Add E2E coverage for importing, editing, viewing and deleting a certificate - #14465
Conversation
| /** The Import Certificate side panel. */ | ||
| importForm: { | ||
| name: '[data-test="input-name"]', | ||
| addToTrustedStore: '[data-test="checkbox-add-to-trusted-store"]', |
There was a problem hiding this comment.
LOW — importForm.addToTrustedStore isn't used anywhere: the import test leaves the flag at its default, and only editForm.addToTrustedStore gets .check()ed. The PR description says this is on purpose. Two cheap ways to make it earn its place: have the import test assert the box starts unchecked (await expect(page.locator(importForm.addToTrustedStore)).not.toBeChecked()), or drop it until a test needs it. 🙂
|
One finding: one LOW. No human review needed. 🎉 I checked every new locator against the templates and they all match: the The tests are well built ✨ The edit is read back by id so a delete plus re-import can't pass for an update, a bystander certificate runs beside both edit and delete, the delete is polled through the API, and the card-capacity guard fails early with a reason.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #14465 +/- ##
==========================================
- Coverage 89.63% 89.63% -0.01%
==========================================
Files 1939 1939
Lines 71551 71551
Branches 9372 9372
==========================================
- Hits 64137 64135 -2
- Misses 7414 7416 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This PR has been merged and conversations have been locked. |
Fixes #14457
Adds
e2e/tests/certificates-import.e2e.ts. It covers the Certificates card on Credentials > Certificates: importing a certificate, editing it, viewing it and deleting it. CSR creation and deletion were already covered incertificates.e2e.ts.The issue title says "the user details page". The body is the spec, so this PR follows the body; triage made the same call for the whole batch (#14454 to #14460).
What it covers
certificate.querymust hold the certificate and the key as pasted,cert_type_CSR: false, andadd_to_trusted_store: false.Every test fails at the start if its rows would not fit on the card, which lists four certificates before its pager. This is the same check the CSR tests use.
The test certificate
e2e/fixtures/test-certificate.tsholds a fixed, test-only self-signed certificate and key, as the ticket asks. It is RSA 2048 with SHA256, CN and SANe2e-import.example.com, CA:FALSE, valid from 2026-01-01 to 2076-01-01. It was generated with Python'scryptographyand is not a credential for anything. The key is unencrypted PKCS#8, which is the form middleware re-exports an imported key in (truenas_crypto_utils.key.export_private_key). So the key the appliance hands back is the imported one plus a trailing newline, and the spec compares PEM after trimming whitespace. Middleware checks only that certificate names are unique (plugins/certificate/crud.py), so the target and the bystander can both carry the same PEM.Testing
e2e:typecheckand the suite will all run first in CI. I checked the code by eye against the lint rules that have failed CI here before, and checked line length with a script.privatekeyandadd_to_trusted_storeare on the app'sCertificateinterface. I could not confirm them against the generatedcertificate.querytype, because the api-client is not on disk here.data-testid against the templates and found nothing at MEDIUM or above. It also re-parsed the checked-in PEM and confirmed that the key matches the certificate.e2e/**, so the E2E workflow runs on it.What I did not change, and why
certificateLocators.importForm.addToTrustedStoreis unused, because the import test leaves the flag at its default and the edit test sets it. I kept it so the import form's locators are complete, the way the other forms' are.deleteCertificaterepeats the shape ofdeleteCsr. The two cards raise the same confirm, but each has its own locators, so I kept them as separate flows.Not covered: importing with a passphrase, the row's Download action, and what the trusted store does to the system once the flag is on.
🤖 Generated with Claude Code