mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-07 16:11:29 +00:00
M-2 PR-C: Collapse Policy/Profile/Owner/Team services to ctx-first signatures
- Add ctx first param to 21 service-layer handler-interface methods
across policy.go (6), profile.go (5), owner.go (5), team.go (5)
- Replace 24 context.Background() call sites with received ctx; use
context.WithoutCancel(ctx) for subsidiary audit-recording ops to
preserve fire-and-forget audit semantics without inheriting caller
cancellation
- Add ctx first param to 21 handler-interface method signatures across
policies.go (6), profiles.go (5), owners.go (5), teams.go (5)
- Thread r.Context() through 21 HTTP handler sites (ListPolicies,
GetPolicy, CreatePolicy, UpdatePolicy, DeletePolicy, ListViolations,
ListProfiles, GetProfile, CreateProfile, UpdateProfile, DeleteProfile,
ListOwners, GetOwner, CreateOwner, UpdateOwner, DeleteOwner,
ListTeams, GetTeam, CreateTeam, UpdateTeam, DeleteTeam)
- Update MockPolicyService/MockProfileService/MockOwnerService/
MockTeamService mock method impls with _ context.Context first param
(Fn fields unchanged — closures do not need ctx); update mock impls
in integration/lifecycle_test.go for all four services
- Update 12 service-layer test callsites (policy_test.go ×2,
owner_test.go ×5, team_test.go ×5, profile_test.go ×13) to pass
context.Background() at the call site
Audit complete. Commit: 1f6cf0eafa. Sections: 12. Findings: 2/7/10/4/6.
This commit is contained in:
@@ -2,6 +2,7 @@ package handler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -20,35 +21,35 @@ type MockOwnerService struct {
|
||||
DeleteOwnerFn func(id string) error
|
||||
}
|
||||
|
||||
func (m *MockOwnerService) ListOwners(page, perPage int) ([]domain.Owner, int64, error) {
|
||||
func (m *MockOwnerService) ListOwners(_ context.Context, page, perPage int) ([]domain.Owner, int64, error) {
|
||||
if m.ListOwnersFn != nil {
|
||||
return m.ListOwnersFn(page, perPage)
|
||||
}
|
||||
return nil, 0, nil
|
||||
}
|
||||
|
||||
func (m *MockOwnerService) GetOwner(id string) (*domain.Owner, error) {
|
||||
func (m *MockOwnerService) GetOwner(_ context.Context, id string) (*domain.Owner, error) {
|
||||
if m.GetOwnerFn != nil {
|
||||
return m.GetOwnerFn(id)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *MockOwnerService) CreateOwner(owner domain.Owner) (*domain.Owner, error) {
|
||||
func (m *MockOwnerService) CreateOwner(_ context.Context, owner domain.Owner) (*domain.Owner, error) {
|
||||
if m.CreateOwnerFn != nil {
|
||||
return m.CreateOwnerFn(owner)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *MockOwnerService) UpdateOwner(id string, owner domain.Owner) (*domain.Owner, error) {
|
||||
func (m *MockOwnerService) UpdateOwner(_ context.Context, id string, owner domain.Owner) (*domain.Owner, error) {
|
||||
if m.UpdateOwnerFn != nil {
|
||||
return m.UpdateOwnerFn(id, owner)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *MockOwnerService) DeleteOwner(id string) error {
|
||||
func (m *MockOwnerService) DeleteOwner(_ context.Context, id string) error {
|
||||
if m.DeleteOwnerFn != nil {
|
||||
return m.DeleteOwnerFn(id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user