Skip to content

test(e2e): prove the deployable identity broker slice in kind - #2987

Merged
ChrisJBurns merged 2 commits into
mainfrom
test/identitybroker-slice7-kind
Nov 26, 2026
Merged

ChrisJBurns merged 2 commits into
mainfrom
test/identitybroker-slice7-kind

Conversation

@ChrisJBurns

@ChrisJBurns ChrisJBurns commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2815 (Phase 1, Slice 7: the slice test). #2538, #2813 and #2814 are merged.

Summary

The Kind suite's hosted AS-1 spec now proves the slice's testable result against a release the chart delivers.

Testable result Where it's proven
mecak8s starts from operator keys, settings, and the embedded gateway entry delivered by the chart installAS1Release always installs five identityBroker.settings, an embedded gateway entry with servers: [], mcp.broker.signingKey, the callback URL, and an OAuth MCP server, so every existing sign-in, session, and isolation spec runs on that release. A new It checks the rendered configuration and that AS-2 publishes the operator's gateway signing key.
The settings take effect Changing only idJAGMaxLifetime to 90s makes mecak8s refuse the chart's clockSkew of 10s (more than a tenth), so mecak8s loads the delivered settings rather than defaults.
No key changes across a restart The existing restart It also checks that AS-1's and AS-2's published key sets are identical before and after the pod restarts.
Broker client key rotation with overlapping keys refuses no request for a key reason Each step of the operator guide's three helm upgrade steps starts and serves a fresh sign-in and session open, and the last step only passes if the broker signs with the new key. The wrong order (the new private key with a key set that holds only the old public key) is refused at startup, which is what protects a rotation while everything runs in one replica.
mecak8s refuses missing or shared keys Missing keys are refused by the chart at render time, so the test asserts the helm template error. For shared keys (the same key in two Secrets, which the chart can't see) and for a key set without the broker client key, the pod never becomes Ready and its log has the startup refusal. A good release is then restored and used.
AS-1 signing key rotation with a fallback (from #2814) A new spec rotates AS-1's signing key through as1Signing.fallbacks. While the old key is a fallback, the JWKS publishes both keys and a token signed before the rotation still opens a session. Once the fallback is removed, the JWKS publishes only the new key and that token is refused.
With the flag off, mecak8s starts as before Already covered: the suite installs its broker-off baseline release before every other spec.

Not proven

  • Requests during a rotation restart. Each rotation step restarts the single replica, a brief outage by design while the broker runs inside mecak8s. The operator guide says so.
  • The agent issuer key across a restart. It isn't published outside the pod.

API compatibility

None. This change is tests only.

Testing

  • Focused local Kind run (-ginkgo.focus='hosted AS-1'): all 11 specs pass. The two rotation specs take 37 s and 34 s; the block adds about two minutes of CI time.
  • Full local task e2e:k8s: 26 passed, 1 failed (remote learning worker failover, a Kubernetes lease API timeout that also fails on its own without this change locally), 3 skipped (live).
  • go vet -tags kind_e2e ./e2e/...: clean. golangci-lint --build-tags kind_e2e: only the four existing revive findings in other files.

The hosted AS-1 spec now installs the identity broker with chart-delivered
settings, an embedded gateway entry, and the gateway's signing key. It checks
that AS-1's and AS-2's published keys survive a restart, rotates the broker
client key through an overlapping key set with helm upgrade, and checks that
mecak8s refuses shared keys and a key set without the broker client key.

Co-authored-by: Mecatl <[email protected]>

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran the focused Kind block locally (-ginkgo.focus='hosted AS-1'): 11 of 11 specs pass. The identity broker unit tests, the chart's Go tests, and helm unittest also pass. Nothing blocking; three points.

1. The rotation spec passes for any order that ends in a valid configuration. AS-1, AS-2, and the broker restart together, so each step reads the key and the key set fresh. Skipping step 1 (new private key straight to a key set holding only the new key) would also pass. The operator guide already says the overlap prevents no refused request in this layout. What actually protects the rotation is that mecak8s refuses the wrong order at startup. Suggest adding that negative step to the spec: the new private key with the old-only jwks.json, expecting "does not hold the broker client key's public key". Then reword the PR table row to "each step of the guide starts and serves sign-in; the wrong order is refused at startup".

2. AS-1 signing key rotation with a fallback isn't exercised in Kind. In this layout it's the one rotation where the overlap is observable: an AS-1 access token issued before a restart still verifies after it, as the restart spec shows. Nothing runs the chart's fallback projection (as1-signing-fallback-0/) in a real pod. #2815's testable result doesn't require it, but #2814's "Done when" lists it. Suggested shape: rotate as1Signing to a new key with the old one as a fallback, check the earlier token still opens a session and the JWKS publishes both keys, then remove the fallback and check that the token is refused. Fine as a follow-up if it doesn't belong here.

3. Risk for operators syncing keys from a secret manager. The guide offers two ways to rotate: change the Secret key name, which rolls the pod, or update the Secret in place and run kubectl rollout restart. The test covers only the first. External Secrets Operator and Secrets Store CSI users will usually take the second, since they can't easily rename keys. If the broker client key and its key set are in two Secrets that sync separately, a restart between the two syncs (a node drain, for example) crash-loops the pod on the key-set check. A line in the guide to keep both in one Secret, synced atomically, would cover it. That's a docs follow-up, not a change to this PR.

… a fallback

The broker client rotation now also shows that signing with a key the key
set does not hold is refused at startup. A new spec rotates AS-1's signing
key through the chart's fallback: tokens signed by the old key open sessions
while it is a fallback and are refused once it is removed. The guide says to
sync the broker client key and its key set together.

Co-authored-by: Mecatl <[email protected]>
@ChrisJBurns

Copy link
Copy Markdown
Contributor Author

Thanks, all three are addressed in 58f64f3.

  1. Wrong order. The broker client rotation spec now starts with the negative step: the new private key with jwks.json holding only the old public key. No pod becomes Ready, and the log has "does not hold the broker client key's public key". The guide's three steps then run as before. I reworded the PR table row as you suggested.
  2. AS-1 signing key rotation with a fallback. This is a new spec, placed last in the block. It rotates as1Signing to a new key with the old one in fallbacks. While the fallback is set, the JWKS publishes both kids, a token signed before the rotation still opens a session, and a fresh sign-in is signed by the new kid. After the fallback is removed, the JWKS publishes only the new kid, the earlier token gets 401 bearer_rejected, and a fresh sign-in still works.
  3. Secret managers. The guide's secret-manager section now says to keep the broker client key and its key set in one Secret that syncs both together, and during a rotation to sync the key set holding both public keys before the new private key.

Focused Kind run: all 11 specs pass. The two rotation specs take 37 s and 34 s.

@ChrisJBurns
ChrisJBurns merged commit 663f88f into main Nov 26, 2026
47 checks passed
@ChrisJBurns
ChrisJBurns deleted the test/identitybroker-slice7-kind branch November 26, 2026 14:37

This branch was successfully deployed

1 active deployment
Preview — 58f64f3b Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phase 1, Slice 7: Deployable — The phase 1 flow runs on operator configuration and keys, deployed by the Helm chart

2 participants