End-to-end testing¶
There are two tiers:
| Tier | Needs | Runs |
|---|---|---|
kind (make kind-e2e) |
Docker or Podman, kubectl | In CI on every PR, and locally |
| Live Entra | A non-production tenant | By hand |
kind tier¶
make kind-e2e creates a kind cluster (pinned kind release, node image pinned
by digest), builds the image over the static binary, loads it, and runs
scripts/kind-e2e.sh:
- The CRD installs and the example
IAMClientvalidates server-side. - The admission policies, applied as shipped, enforce "admins create, owners
maintain" against a real API server. The script impersonates the Flux
provisioner, a platform admin, an owner (with the per-client Role) and a
non-admin with create rights, and checks: who may create and delete; that
owners can change
redirectURIsand nothing else; that approval annotations are admin-only; thatlast-modified-byis stamped and cannot be forged; and that HTTP, wildcard, foreign-domain and suffix-trick redirect URIs are refused. - The controller image starts with the shipped RBAC and Deployment, as non-root, and fails closed ("workload identity required") without a federated token.
make kind-e2e-ci does the same on a fresh cluster and deletes it afterwards.
With Podman instead of Docker, set KIND_EXPERIMENTAL_PROVIDER=podman.
Live Entra tier¶
Charter's Graph behaviour (eventual consistency, throttling, permission edge cases) only shows up against a real tenant, so these tests run the controller against a non-production Entra tenant and a local cluster. They are not in CI: that would put a tenant credential in GitHub.
Setup¶
- A development tenant and a controller app registration with a client
secret in
~/.config/charter/dev.env: see bootstrap the Entra identity. - A kind cluster with the CRD:
- For OpenBao delivery, External Secrets and OpenBao in dev mode:
and a
helm repo add external-secrets https://charts.external-secrets.io helm repo add openbao https://openbao.github.io/openbao-helm helm upgrade --install external-secrets external-secrets/external-secrets \ -n external-secrets --create-namespace --wait helm upgrade --install openbao openbao/openbao -n openbao --create-namespace \ --set server.dev.enabled=true --set server.dev.devRootToken=root \ --set injector.enabled=false --wait kubectl -n external-secrets create secret generic openbao-token --from-literal=token=rootClusterSecretStorenamedopenbaopointing athttp://openbao.openbao.svc:8200, KV v2 mountsecret(see delivering to OpenBao). - Run the controller with short timings so rotation behaviour is visible:
set -a; . ~/.config/charter/dev.env; set +a ALLOWED_REDIRECT_DOMAINS=.e2e.example.com \ ALLOWED_PUSH_SECRET_STORES=openbao DEFAULT_PUSH_SECRET_STORE=openbao \ ROTATION_GRACE_HOURS=0 RUST_LOG=info,charter_iam=debug \ cargo runROTATION_GRACE_HOURS=0makes the push-sync check the only thing holding back revocation, which is what the rotation scenarios test.
Scenarios¶
Each scenario lists what to do and what must be true afterwards. Read the
audit trail from the controller log, and Entra state with az rest against
/applications(uniqueName='charter-team-e2e-<name>').
| # | Scenario | Do | Expect |
|---|---|---|---|
| 1 | Create | Apply a client with approval annotations | Ready=True; app, SP, owners (you + controller), one password matching the Secret's key-id; the delivered secret can get a token |
| 2 | Drift | Rename the app, add a redirect URI and a password via Graph; wait 30 seconds; poke | drift_detected, update_application, remove_password (unknown_credential); Entra back to spec |
| 3 | Approval gate | Change secretRotation without a new change-ref |
approval_check denied, PendingApproval; nothing changes in Entra |
| 4 | Approval | Set a new change-ref | Applied; status.changeRef updated |
| 5 | Forced rotation | Remove client-secret from the Secret |
One add_password, deliver_secret; previous key kept (grace) |
| 6 | Grace expiry | Restart with ROTATION_GRACE_HOURS=0 |
Previous key removed (rotated_out) |
| 7 | Lifetime shortened | Approve a shorter secretRotation |
One add_password (lifetime_shortened); a "waiting for replication" log line instead of a second password; old key revoked |
| 8 | Push | Client with pushSecret: {} |
apply_push_secret; SecretPushed=True; every key in OpenBao equals the Secret |
| 9 | Push gating | Forced rotation with push | Old key kept until refreshTime passes the rotation, then revoked; OpenBao has the new secret |
| 10 | Store not allowed | pushSecret.clusterSecretStore: other with a new change-ref |
PolicyViolation; existing PushSecret untouched |
| 11 | Push removed | Remove pushSecret with a new change-ref |
delete_push_secret; OpenBao path and metadata gone |
| 12 | Delete, Retain | Delete a client | Passwords revoked, retain_application, app still present |
| 13 | Delete, Delete | Delete a client with deletionPolicy: Delete and pushSecret |
delete_push_secret, delete_application, OpenBao path gone |
Compare OpenBao with the Secret without printing values, for example by
hashing both sides or comparing in a script that prints only match=True/False.
Expected noise¶
Replication lag produces occasional failed records that converge on retry;
see troubleshooting. A
scenario fails if state does not converge within a few minutes, not because a
transient failed record appeared.
Cleaning up¶
Retained apps stay in the tenant: delete them in the Entra admin center. Apps
deleted with Delete sit in Deleted applications for 30 days and block
reuse of the same namespace and name until then; use fresh names per run.