From ed989d81fd71238c1bd1dae8fb162c3980e37323 Mon Sep 17 00:00:00 2001 From: shankar0123 Date: Sun, 22 Mar 2026 16:02:36 -0400 Subject: [PATCH] fix: wire issuer registry in revocation tests, correct CRL/OCSP handler test URLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Service tests: newRevocationTestService() was missing SetIssuerRegistry(), causing all 8 CRL/OCSP tests to fail with "issuer registry not configured". Handler tests: CRL tests used /api/v1/issuers/{id}/crl but handler parses /api/v1/crl/{id}. OCSP tests used query string ?serial=X but handler expects path param /api/v1/ocsp/{id}/{serial}. Fixed all 9 test URLs. All issues pre-date CI on v2-dev — introduced during M15b. Co-Authored-By: Claude Opus 4.6 --- .../api/handler/certificate_handler_test.go | 18 +++++++++--------- internal/service/revocation_test.go | 3 +++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/internal/api/handler/certificate_handler_test.go b/internal/api/handler/certificate_handler_test.go index 176b7af..63c8986 100644 --- a/internal/api/handler/certificate_handler_test.go +++ b/internal/api/handler/certificate_handler_test.go @@ -1073,7 +1073,7 @@ func TestGetDERCRL_Success(t *testing.T) { } handler := NewCertificateHandler(mock) - req := httptest.NewRequest(http.MethodGet, "/api/v1/issuers/iss-local/crl", nil) + req := httptest.NewRequest(http.MethodGet, "/api/v1/crl/iss-local", nil) req = req.WithContext(contextWithRequestID()) w := httptest.NewRecorder() @@ -1098,7 +1098,7 @@ func TestGetDERCRL_IssuerNotFound(t *testing.T) { } handler := NewCertificateHandler(mock) - req := httptest.NewRequest(http.MethodGet, "/api/v1/issuers/nonexistent/crl", nil) + req := httptest.NewRequest(http.MethodGet, "/api/v1/crl/nonexistent", nil) req = req.WithContext(contextWithRequestID()) w := httptest.NewRecorder() @@ -1117,7 +1117,7 @@ func TestGetDERCRL_NotSupported(t *testing.T) { } handler := NewCertificateHandler(mock) - req := httptest.NewRequest(http.MethodGet, "/api/v1/issuers/iss-acme/crl", nil) + req := httptest.NewRequest(http.MethodGet, "/api/v1/crl/iss-acme", nil) req = req.WithContext(contextWithRequestID()) w := httptest.NewRecorder() @@ -1132,7 +1132,7 @@ func TestGetDERCRL_NotSupported(t *testing.T) { func TestGetDERCRL_MethodNotAllowed(t *testing.T) { mock := &MockCertificateService{} handler := NewCertificateHandler(mock) - req := httptest.NewRequest(http.MethodPost, "/api/v1/issuers/iss-local/crl", nil) + req := httptest.NewRequest(http.MethodPost, "/api/v1/crl/iss-local", nil) req = req.WithContext(contextWithRequestID()) w := httptest.NewRecorder() @@ -1155,7 +1155,7 @@ func TestHandleOCSP_Success(t *testing.T) { } handler := NewCertificateHandler(mock) - req := httptest.NewRequest(http.MethodGet, "/api/v1/issuers/iss-local/ocsp?serial=12345", nil) + req := httptest.NewRequest(http.MethodGet, "/api/v1/ocsp/iss-local/12345", nil) req = req.WithContext(contextWithRequestID()) w := httptest.NewRecorder() @@ -1174,7 +1174,7 @@ func TestHandleOCSP_Success(t *testing.T) { func TestHandleOCSP_MissingSerial(t *testing.T) { mock := &MockCertificateService{} handler := NewCertificateHandler(mock) - req := httptest.NewRequest(http.MethodGet, "/api/v1/issuers/iss-local/ocsp", nil) + req := httptest.NewRequest(http.MethodGet, "/api/v1/ocsp/iss-local/", nil) req = req.WithContext(contextWithRequestID()) w := httptest.NewRecorder() @@ -1193,7 +1193,7 @@ func TestHandleOCSP_IssuerNotFound(t *testing.T) { } handler := NewCertificateHandler(mock) - req := httptest.NewRequest(http.MethodGet, "/api/v1/issuers/nonexistent/ocsp?serial=ABC123", nil) + req := httptest.NewRequest(http.MethodGet, "/api/v1/ocsp/nonexistent/ABC123", nil) req = req.WithContext(contextWithRequestID()) w := httptest.NewRecorder() @@ -1212,7 +1212,7 @@ func TestHandleOCSP_CertNotFound(t *testing.T) { } handler := NewCertificateHandler(mock) - req := httptest.NewRequest(http.MethodGet, "/api/v1/issuers/iss-local/ocsp?serial=UNKNOWN", nil) + req := httptest.NewRequest(http.MethodGet, "/api/v1/ocsp/iss-local/UNKNOWN", nil) req = req.WithContext(contextWithRequestID()) w := httptest.NewRecorder() @@ -1226,7 +1226,7 @@ func TestHandleOCSP_CertNotFound(t *testing.T) { func TestHandleOCSP_MethodNotAllowed(t *testing.T) { mock := &MockCertificateService{} handler := NewCertificateHandler(mock) - req := httptest.NewRequest(http.MethodPost, "/api/v1/issuers/iss-local/ocsp?serial=12345", nil) + req := httptest.NewRequest(http.MethodPost, "/api/v1/ocsp/iss-local/12345", nil) req = req.WithContext(contextWithRequestID()) w := httptest.NewRecorder() diff --git a/internal/service/revocation_test.go b/internal/service/revocation_test.go index c02baa3..5b0e621 100644 --- a/internal/service/revocation_test.go +++ b/internal/service/revocation_test.go @@ -19,6 +19,9 @@ func newRevocationTestService() (*CertificateService, *mockCertRepo, *mockRevoca policyService := NewPolicyService(policyRepo, auditService) certService := NewCertificateService(certRepo, policyService, auditService) certService.SetRevocationRepo(revocationRepo) + certService.SetIssuerRegistry(map[string]IssuerConnector{ + "iss-local": &mockIssuerConnector{}, + }) return certService, certRepo, revocationRepo, auditRepo }