Files
certctl/cmd
shankar0123 018c99b90c Bundle 0.7-extended (Coverage Audit Extension): cmd/agent dispatch coverage — 57.7% -> 73.1%
cmd/agent/dispatch_test.go (~520 LoC, 18 tests) lifts cmd/agent
overall line coverage 57.7% -> 73.1% (+15.4pp). Same httptest-backed
pattern as the existing agent_test.go.

Functions covered (per-function deltas):
  executeCSRJob              14.1% -> 64.1%
  executeDeploymentJob       46.7% -> 66.7%
  Run                         0.0% -> 62.2%
  markRetired                 0.0% -> 100.0%
  getEnvDefault               0.0% -> 100.0%
  getEnvBoolDefault           0.0% -> 100.0%
  verifyAndReportDeployment   0.0% -> partial (probe-failure +
                                              nil-target-id arms)
  pollForWork                58.1% -> 67.7% (Run-driven coverage)
  sendHeartbeat              84.2% -> 100.0% (Run-driven)
  fetchCertificate           83.3% -> 83.3% (deployment-test driven)

Test groups
  - executeCSRJob: happy path (asserts CSR PEM submission +
    key-file mode 0600 + EC PRIVATE KEY block); empty CN
    failure-report; CSR rejection (400) failure-report
  - executeDeploymentJob: certificate fetch failure; missing
    local key; unknown target connector type
  - markRetired: signal closes once; second mark non-panicking
    via sync.Once
  - getEnvDefault / getEnvBoolDefault: every truthy/falsy spelling
    + unrecognized-falls-back-to-default + empty
  - Run: context-cancel exits with context.Canceled; HTTP 410
    Gone heartbeat surfaces ErrAgentRetired
  - verifyAndReportDeployment: probe-failure path + nil-target-id
    short-circuit

Remaining gap (cmd/agent 73.1% < 75% target): mainly main()
(0.0%) which calls os.Exit and is hard to test without subprocess
plumbing. Tracked as cmd/agent-main-extended (defer; subprocess
test requires re-architecting around testable Run wrapper, which
already exists and is now tested directly).

Verification
  - go test -short -count=1 ./cmd/agent/... PASS
  - 17.1s wall time (within budget)
  - go vet clean

Audit deliverables
  - extension-progress.md: 0.7-extended marked DONE with delta

Closes (mostly): cmd/agent overall coverage gap from Bundle 0.7
Bundle: 0.7-extended (Coverage Audit Extension)
2026-04-27 19:05:08 +00:00
..