Skip to content
This repository was archived by the owner on Aug 5, 2026. It is now read-only.

test(e2e): real apiRef chain — CDC ↔ authn JWT ↔ snowplow with extras - #8

Merged
braghettos merged 1 commit into
mainfrom
test/apiref-e2e-kind
Jun 20, 2026
Merged

test(e2e): real apiRef chain — CDC ↔ authn JWT ↔ snowplow with extras#8
braghettos merged 1 commit into
mainfrom
test/apiref-e2e-kind

Conversation

@braghettos

Copy link
Copy Markdown
Collaborator

A real, kind-based end-to-end test of the apiRef status source against real authn + real snowplow (1.1.1) — not stubs. It exercises the actual CDC client code (`internal/authn`, `internal/snowplow`, `internal/composition.SnowplowAPIResolver`).

Chain proven

```
projected SA token (file)
─ authn.Client.Token ─▶ authn POST /serviceaccount/login (TokenReview → JWT + clientconfig)
─ snowplow.Client.Resolve(Bearer JWT, extras) ─▶ snowplow GET /call (resolves a RESTAction)
─▶ RESTAction echoes the request extras ─▶ .api.echo.args
```

Assertion

Both static extras (`region`, from `apiRef.extras`) and per-instance extras (`compositionName`/`compositionNamespace`/`compositionId`, injected by the resolver, request-wins) round-trip through the authn-issued JWT and snowplow's RESTAction resolution:

`.api.echo.args == {cn: demo-app, cns: apps, cid: uid-e2e-123, region: eu}`

Evidence (from the passing run)

  • authn: `serviceaccount auth succeeded username=cdc-e2e groups=krateo:cdc-e2e` + CSR signed.
  • snowplow: decoded the JWT (`user={cdc-e2e,[krateo:cdc-e2e]}`), authorized via SubjectAccessReview, `base dict for api resolver dict={compositionId,compositionName,compositionNamespace,region}`, then `RESTAction successfully resolved name=status-sources`.
  • test: PASS (10s).

Layout

  • `internal/composition/apiref_kind_e2e_test.go` — env-driven, `//go:build e2e` (stays out of the unit suite).
  • `hack/apiref-e2e/` — reproducible harness: `run.sh` (cluster + build images from source + deploy + mint token + port-forward + test), `manifests/`, and a README.

Requires docker, kind, kubectl, go, and `../authn` + `../snowplow` checkouts. Run: `hack/apiref-e2e/run.sh`.

🤖 Generated with Claude Code

Adds a kind-based end-to-end test proving the apiRef status source against real
authn and real snowplow (1.1.1), exercising the actual CDC client code:

  projected SA token -> authn /serviceaccount/login (TokenReview -> JWT)
    -> snowplow /call (Bearer JWT) -> RESTAction resolution
    -> request extras echoed back into .api.echo.args

Asserts both static (apiRef.extras: region) and per-instance (compositionName/
Namespace/Id, request-wins) extras round-trip through the authn-issued JWT and
snowplow's resolution. Build-tagged (e2e) so it stays out of the unit suite.

- internal/composition/apiref_kind_e2e_test.go: the env-driven test.
- hack/apiref-e2e/: reproducible harness (run.sh + manifests + README).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@braghettos
braghettos merged commit 7626220 into main Jun 20, 2026
3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant