Files
certctl/internal/connector/target/validate_only_smoke_test.go
shankar0123 8b75e0311b chore: rename Go module path to github.com/certctl-io/certctl
Mechanical sed across the main go.mod's module declaration, the f5-mock-icontrol
sub-module's go.mod, every Go file's import path (361 files), and a rebuild of
the checked-in f5-mock-icontrol binary so its embedded build-info reflects the
new module path. No behavior change.

Choice B from cowork/transfer-certctl-to-org.md, executed 2026-05-04. Choice A
(keep module path declared as github.com/shankar0123/certctl regardless of
repo URL) shipped on the day of the org transfer (2026-05-03) since we had no
external Go consumers; this commit closes that deferral.

Backward-compat: GitHub HTTP redirects continue to forward
github.com/shankar0123/certctl → github.com/certctl-io/certctl at the URL
level, but Go's module proxy uses the path declared in go.mod as the
canonical name. Pre-fix, anyone trying `go get github.com/certctl-io/certctl/...`
hit a "module path mismatch" error because go.mod said
github.com/shankar0123/certctl and the URL they fetched it from said
certctl-io/certctl. Post-fix, the canonical name and the URL agree, so
go get / go install / external Go consumers / Go-tooling integrations
work cleanly via either the new path (preferred) or the old path (which
redirects and Go follows the redirect for source fetch).

Anyone still importing the old path inside their own code keeps working
provided they update their go.mod's `require` line to match — the module
path declared in their consumer's go.sum / go.mod is the authoritative
import name, so a mass sed across their import statements is the migration
on the consumer side. No external consumers exist today.

Diff shape:
  361 *.go files  — import path replacement only
    2 go.mod     — module declaration replacement only
    1 binary     — deploy/test/f5-mock-icontrol/f5-mock-icontrol rebuilt
                   so embedded build-info reflects the new path (8618965 vs
                   8618933 bytes; 32-byte diff is the build-info change)

  Total: 364 files, 730 insertions / 730 deletions, net-zero size, pure
  mechanical substitution.

Verification:
  gofmt: 17 files needed re-alignment after sed (the new path is one char
    shorter than the old, so column-aligned import groups drifted). Applied
    `gofmt -w` to fix.
  go mod tidy: clean exit on both modules.
  go vet ./...: clean exit.
  go build ./...: clean exit.
  go test -short -count=1 on representative packages: all green
    (internal/domain, internal/validation, internal/crypto, internal/crypto/signer,
    cmd/agent). Test output now reads `ok github.com/certctl-io/certctl/...`
    confirming the module path resolves correctly.
  binary: f5-mock-icontrol rebuilt; `strings | grep shankar0123` returns
    nothing; `strings | grep certctl-io/certctl` shows the new module path
    embedded in build-info.

Files intentionally NOT touched in this commit:
  README.md / CHANGELOG.md / docs/ / etc. — already swept to certctl-io
    URLs in commit 0729ee4 (the post-transfer URL refresh). This commit is
    purely the Go-tooling layer.
  Scarf pixels (`shankar0123.docker.scarf.sh/...`) — Scarf-account
    namespace, not a Go import or GitHub repo URL. Stays.

This is a non-blocking, non-customer-impacting change. Operators pulling
container images, running `make verify`, hitting the API, or installing the
agent see no functional difference. Only Go-tooling consumers (none today)
are affected, and they're enabled — not broken — by this commit.
2026-05-04 00:30:29 +00:00

108 lines
5.2 KiB
Go

package target_test
// Phase 3 of the deploy-hardening I master bundle: per-connector
// regression smoke pinning the default ValidateOnly stub returns
// the sentinel for every one of the 13 connectors. This test lives
// in target_test (external test package) so it can import each
// connector concretely + assert the interface contract.
//
// As Phases 4-9 replace each connector's stub with a real
// validate-with-the-target implementation, the corresponding
// per-connector entry in TestEveryConnectorDefaultsToSentinel
// MUST be deleted (or the test will fail because the real
// implementation no longer returns the sentinel). That deletion
// IS the bookkeeping that the operator-visible bit + behavior
// change are wired together.
import (
"context"
"encoding/json"
"errors"
"testing"
"github.com/certctl-io/certctl/internal/connector/target"
// apache removed Phase 5 — real ValidateOnly implementation now in apache.go.
"github.com/certctl-io/certctl/internal/connector/target/caddy"
"github.com/certctl-io/certctl/internal/connector/target/envoy"
// f5 removed Phase 8 — real ValidateOnly implementation now in validate_only.go.
// haproxy removed Phase 6 — real ValidateOnly implementation now in haproxy.go.
// iis removed Phase 8 — real ValidateOnly implementation now in validate_only.go.
// javakeystore removed Phase 9 — real ValidateOnly implementation now in validate_only.go.
// k8ssecret removed Phase 9 — real ValidateOnly implementation now in validate_only.go.
// nginx removed Phase 4 — real ValidateOnly implementation now in nginx.go.
// postfix removed Phase 7 — real ValidateOnly implementation now in postfix.go.
// ssh removed Phase 9 — real ValidateOnly implementation now in validate_only.go.
"github.com/certctl-io/certctl/internal/connector/target/traefik"
// wincertstore removed Phase 9 — real ValidateOnly implementation now in validate_only.go.
)
// connectorsAtPhase3 is the canonical list of connectors that, as
// of Phase 3, return ErrValidateOnlyNotSupported from
// ValidateOnly. Each entry is a (name, factory) tuple; the factory
// returns a target.Connector via the connector's bare-NewConnector
// constructor pattern. As Phases 4-9 land, the corresponding
// connector is REMOVED from this list — its real ValidateOnly
// implementation is then exercised in the per-connector test
// suite, NOT here.
//
// CI guard rationale: a future PR that adds a 14th connector
// without wiring ValidateOnly fails this test (the sentinel
// contract is not satisfied). A future PR that implements a real
// ValidateOnly for, say, NGINX, but forgets to remove its entry
// from this list, fails this test (real impl no longer returns
// the sentinel). Both are the load-bearing bookkeeping protections.
var connectorsAtPhase3 = []struct {
name string
// new returns a fresh Connector instance. The default
// ValidateOnly stub doesn't dereference any field on the
// receiver, so a zero-value &pkg.Connector{} is sufficient
// to satisfy the interface and exercise the sentinel return.
// Phases 4-9 introduce real validate-with-the-target impls
// that DO read fields; those connectors will need a populated
// constructor here OR (more likely) be removed from this list
// entirely and exercised in their own per-connector test
// suite.
new func() target.Connector
}{
// apache removed Phase 5 — its ValidateOnly is now the real
// implementation; tested directly in apache/apache_atomic_test.go.
// caddy: file mode returns sentinel (no validate-with-target);
// api mode is real-impl. Empty Connector hits the file-mode path.
{"caddy", func() target.Connector { return &caddy.Connector{} }},
// envoy: no validate-with-target command exists; always sentinel.
{"envoy", func() target.Connector { return &envoy.Connector{} }},
// f5 removed Phase 8 — Authenticate-probe real impl.
// haproxy removed Phase 6 — `haproxy -c -f` real impl.
// iis removed Phase 8 — Get-WebSite probe real impl.
// javakeystore removed Phase 9 — `keytool -list` real impl.
// k8ssecret removed Phase 9 — GetSecret RBAC probe real impl.
// nginx removed Phase 4 — `nginx -t` real impl.
// postfix removed Phase 7 — `postfix check` / `doveconf -n` real impl.
// ssh removed Phase 9 — Connect probe real impl.
// traefik: no validate-with-target command exists; always sentinel.
{"traefik", func() target.Connector { return &traefik.Connector{} }},
// wincertstore removed Phase 9 — `Get-ChildItem Cert:\` probe.
}
func TestEveryConnectorDefaultsToSentinel(t *testing.T) {
// Expected list size shrinks as Phases 4-9 land their real
// ValidateOnly implementations. Phase 4 removed nginx.
const expectedAtCurrentPhase = 3
if len(connectorsAtPhase3) != expectedAtCurrentPhase {
t.Fatalf("connectors-at-phase list = %d entries, want %d (drift in the 13-connector inventory)", len(connectorsAtPhase3), expectedAtCurrentPhase)
}
for _, c := range connectorsAtPhase3 {
t.Run(c.name, func(t *testing.T) {
conn := c.new()
err := conn.ValidateOnly(context.Background(), target.DeploymentRequest{
CertPEM: "ignored-by-stub",
ChainPEM: "ignored",
TargetConfig: json.RawMessage(`{}`),
})
if !errors.Is(err, target.ErrValidateOnlyNotSupported) {
t.Errorf("got %v, want ErrValidateOnlyNotSupported", err)
}
})
}
}