fix: Updated the domain field update function to decrypt and check the certificate expire#1075
fix: Updated the domain field update function to decrypt and check the certificate expire#1075choonkeat1986 wants to merge 1 commit into
Conversation
a92a025 to
e2c291c
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the domains Update use case to preserve existing certificate metadata while allowing certificate replacement with expiration validation, and adjusts unit tests to reflect the additional pre-fetch behavior.
Changes:
- Fetch the existing domain (with certificate data) before updating, and reuse existing cert fields unless a new cert is provided.
- When a new provisioning cert is provided, validate its expiration and (when available) update the cert in the configured cert store.
- Update
TestUpdatemocks to account for the new initialGetByNamecall.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| internal/usecase/domains/usecase.go | Adds pre-fetch + certificate expiration validation and cert-store handling in Update. |
| internal/usecase/domains/usecase_test.go | Updates TestUpdate expectations for the added GetByName call. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1075 +/- ##
==========================================
+ Coverage 43.61% 43.86% +0.24%
==========================================
Files 143 143
Lines 13626 13663 +37
==========================================
+ Hits 5943 5993 +50
+ Misses 7118 7100 -18
- Partials 565 570 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
bb934a6 to
9b6f7d2
Compare
84d15a4 to
4045c4b
Compare
|
@choonkeat1986 - Have you tested these changes with Postgres + Vault? |
…e certificate expire
4045c4b to
40d9f00
Compare
vagrant@dmt-dev-ck:~/workspace/deployment/console$ cd /home/vagrant/workspace/deployment/console && go version && go test ./internal/usecase/domains/... ./pkg/secrets/vault/... ./pkg/db/... 2>&1 | tail -40
go version go1.25.0 linux/amd64
ok github.com/device-management-toolkit/console/internal/usecase/domains 0.054s
ok github.com/device-management-toolkit/console/pkg/secrets/vault 0.005s
ok github.com/device-management-toolkit/console/pkg/db 0.004s
vagrant@dmt-dev-ck:~/workspace/deployment/console$ cd /home/vagrant/workspace/deployment/console && go test ./internal/certificates/... -run Vault -v 2>&1 | tail -30
=== RUN TestLoadOrGenerateWebServerCertificateWithVault_LoadsFromVault
2026/07/15 03:36:14 Web server certificate loaded from Vault
--- PASS: TestLoadOrGenerateWebServerCertificateWithVault_LoadsFromVault (0.05s)
PASS
ok github.com/device-management-toolkit/console/internal/certificates 0.056s |
PR Checklist
[x ] Unit Tests have been added for new changes
API tests have been updated if applicable
[x ] All commented code has been removed
If you've added a dependency, you've ensured license is compatible with Apache 2.0 and clearly outlined the added dependency.
What are you changing?
Fixing the issue on the domain certificate expire date after edit the existing domain profile and reupload the certificate.
#1019