Skip to content

test: OidcFederation strategy coverage (@cipherstash/auth 0.39.0)#101

Merged
coderdan merged 4 commits into
chore/bump-cipherstash-stack-0.37from
test/oidc-federation-scaffold
Jun 6, 2026
Merged

test: OidcFederation strategy coverage (@cipherstash/auth 0.39.0)#101
coderdan merged 4 commits into
chore/bump-cipherstash-stack-0.37from
test/oidc-federation-scaffold

Conversation

@coderdan
Copy link
Copy Markdown
Contributor

@coderdan coderdan commented Jun 6, 2026

Summary

Adds contract coverage for the new OidcFederationStrategy auth strategy (introduced in stack-auth, surfaced to JS via @cipherstash/auth), and bumps the integration-tests dep to the version that ships it.

Key finding: the export was never missing in cipherstash-suiteOidcFederationStrategy shipped in @cipherstash/auth@0.39.0 (current npm latest). This repo's integration-tests just pinned ^0.38.0, the version published immediately before it. So the fix is here, not upstream.

The FFI boundary duck-types on the AuthStrategy = { getToken: () => Promise<{ token: string }> } contract (src/index.cts) and never branches on strategy type, so OIDC coverage is consumer-side wiring mirroring js-strategy.test.ts (Neon) and wasm-round-trip.test.ts (wasm).

Changes

  • Bump @cipherstash/auth ^0.38.0^0.39.0 in integration-tests.
  • New tests/oidc-federation.test.ts — two contract tests that run in CI unconditionally (no credentials, no network):
    • the real published OidcFederationStrategy constructs via .create(region, workspaceId, getJwt) and is structurally assignable to the FFI's AuthStrategy;
    • a strategy threads through newClient with a rejected getToken propagating as a client error.
  • 0.39.0 breaking change handled: AccessKeyStrategy.create now takes the full workspace CRN (was the <region>.<provider> segment). Updated wasm-round-trip.test.ts, js-strategy.test.ts, and the event-loop-exit-jsbacked.cjs fixture, dropping the now-needless CRN-splitting.

Why no live end-to-end round-trip

A federation round-trip (third-party JWT → CTS token → encrypt/decrypt) is deliberately not tested here:

  • The FFI ⇄ wasm-strategy ⇄ ZeroKMS encrypt/decrypt path is already proven via AccessKeyStrategy — the strategy type is irrelevant to the FFI, which only calls getToken.
  • The OIDC-specific exchange (getJwt/api/authorise → CTS token) lives entirely inside stack-auth, tested hermetically there with MockAuthServer + a base-URL override that the published consumer API doesn't expose.
  • A live round-trip needs a fresh OIDC JWT per run (they expire in minutes), so it can't be driven from a static CI secret without real IdP infra — and gating it on an env var CI never sets would leave it permanently skipped: green but inert. (An earlier revision of this PR had exactly that; it's been removed.)

Testing

  • npx vitest run tests/oidc-federation.test.ts2 passed, 0 skipped
  • Full suite on 0.39.0: 136 passed, 2 failures — both the pre-existing keyset.test.ts workspace-permission issue (grant_keyset … Forbidden), unrelated to this change.

Stacked on #100 (Rust deps → 0.37.0); merge that first and GitHub will retarget this to main.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 6, 2026

Looking for one thing? Review this PR in Change Stack to search files, summaries, diffs, and code without losing your place.

Review Change Stack

📝 Walkthrough

Walkthrough

This PR upgrades @cipherstash/auth from 0.38.0 to 0.39.0 and updates integration test fixtures to align with the new library API. All AccessKeyStrategy.create() calls now pass the full workspace CRN directly instead of parsing it; additionally, a comprehensive integration test suite for OidcFederationStrategy is introduced.

Changes

Auth library upgrade and integration tests

Layer / File(s) Summary
Dependency upgrade
integration-tests/package.json
@cipherstash/auth dependency updated from ^0.38.0 to ^0.39.0.
AccessKeyStrategy wiring updates
integration-tests/tests/fixtures/event-loop-exit-jsbacked.cjs, integration-tests/tests/js-strategy.test.ts, integration-tests/tests/wasm-round-trip.test.ts
All three files remove CRN region parsing logic and now pass the full CS_WORKSPACE_CRN directly to AccessKeyStrategy.create(). Comment in the fixture is updated to reflect that 0.39.0 handles region extraction internally.
OidcFederationStrategy integration tests
integration-tests/tests/oidc-federation.test.ts
New test suite adds a helper function to parse workspace CRNs, a contract test verifying OidcFederationStrategy.getToken behavior and error propagation, and a gated end-to-end test that federates an OIDC JWT, creates a client, encrypts/decrypts plaintext, and validates the round-trip.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • cipherstash/protectjs-ffi#90: Both PRs modify integration-tests/tests/wasm-round-trip.test.ts to align with updated @cipherstash/auth behavior introduced in wasm test work.
  • cipherstash/protectjs-ffi#96: Both PRs update integration-test auth wiring around AccessKeyStrategy.create() to use the full CS_WORKSPACE_CRN.

Suggested reviewers

  • freshtonic
  • auxesis

Poem

🐰 A library upgraded, old parsers retire,
The full CRN flows where it's needed—no wire.
OIDC now tested, encryption round-tripped,
The auth dance grows richer, compatibility equipped! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding OidcFederation strategy test coverage and upgrading to @cipherstash/auth 0.39.0. It is concise, specific, and directly reflects the primary objectives of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/oidc-federation-scaffold

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderdan coderdan changed the title test: scaffold pending OidcFederation strategy tests test: OidcFederation strategy coverage (@cipherstash/auth 0.39.0) Jun 6, 2026
coderdan added 2 commits June 6, 2026 10:53
Add integration-tests/tests/oidc-federation.test.ts covering the new
stack-auth OidcFederation strategy (surfaced via @cipherstash/auth).

The FFI boundary duck-types on the AuthStrategy { getToken } contract and
never branches on strategy type, so OIDC coverage is consumer-side wiring
mirroring js-strategy.test.ts and wasm-round-trip.test.ts.

The hermetic end-to-end block is describe.skip-ped pending two upstream
additions in @cipherstash/auth (tracked in cipherstash-suite):
  - OidcFederation is not exported yet (0.38.0 exposes only Auto/AccessKey/
    OAuth strategies)
  - MockAuthServer needs an OIDC token-exchange mock + base-URL override

A live contract test runs today (no creds/network): it asserts a rejected
getToken propagates as a client error through the exact opts.strategy path
the real OidcFederation will travel.
The OidcFederationStrategy export already shipped in @cipherstash/auth
0.39.0 (npm latest); the prior ^0.38.0 pin predated it. Bump the
integration-tests dep and replace the pending scaffold with real coverage:

  - Contract tier (runs in CI, no creds): the published
    OidcFederationStrategy constructs via .create and satisfies the FFI's
    structural AuthStrategy contract; a rejected getToken propagates through
    newClient.
  - End-to-end tier (describe.skipIf on CS_OIDC_JWT + dataset creds): a real
    federation round-trip — third-party JWT -> CTS token -> encrypt/decrypt.

A hermetic MockAuthServer round-trip isn't reachable through the published
consumer API (napi-only mock; no base-URL override on the public .create),
so the live exchange is env-gated rather than mocked.

0.39.0 also makes AccessKeyStrategy.create take the full workspace CRN
(was the <region>.<provider> segment). Update the existing wasm-round-trip
and js-strategy suites and the event-loop-exit fixture to pass the full CRN,
dropping the now-needless CRN-splitting.
@coderdan coderdan force-pushed the test/oidc-federation-scaffold branch from e2cdaa0 to 6e891ab Compare June 6, 2026 02:53
@coderdan coderdan changed the base branch from main to chore/bump-cipherstash-stack-0.37 June 6, 2026 02:53
- E2E: wrap the wasm OidcFederationStrategy in a plain { getToken } object
  before handing it to the Neon newClient. The JsBacked path is proven
  against this shape (js-strategy.test.ts); passing a wasm-bindgen class
  instance straight through was untested and the block is skip-gated, so a
  failure there would have shipped green.
- Contract: drop the vacuous expect(asStrategy).toBeDefined() (always true)
  in favour of asserting getToken is callable on the contract-typed handle.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the integration-tests package to consume @cipherstash/auth@^0.39.0 and adds integration coverage for the newly available OidcFederationStrategy (via the wasm-inline entry), along with updating existing AccessKeyStrategy wiring to match the 0.39.0 API change.

Changes:

  • Bump integration-tests dependency @cipherstash/auth from ^0.38.0 to ^0.39.0.
  • Add tests/oidc-federation.test.ts with a CI-safe contract suite plus an env-gated end-to-end federation + encrypt/decrypt round-trip.
  • Update existing tests/fixtures to pass the full workspace CRN into AccessKeyStrategy.create (0.39.0 behavior).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
integration-tests/tests/wasm-round-trip.test.ts Update AccessKeyStrategy.create call site to pass full workspace CRN (0.39.0 API).
integration-tests/tests/oidc-federation.test.ts Add OIDC Federation strategy contract + env-gated E2E test coverage.
integration-tests/tests/js-strategy.test.ts Update AccessKeyStrategy.create call site to pass full workspace CRN (0.39.0 API).
integration-tests/tests/fixtures/event-loop-exit-jsbacked.cjs Update fixture strategy construction to pass full workspace CRN (0.39.0 API).
integration-tests/package.json Bump @cipherstash/auth dependency to ^0.39.0.
integration-tests/package-lock.json Lockfile updates for @cipherstash/auth@0.39.0 and peer package versions.
Files not reviewed (1)
  • integration-tests/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The skip-gated end-to-end round-trip relied on a static CS_OIDC_JWT, which
can't work: OIDC JWTs expire in minutes, and CI sets no such secret, so the
block was skipped on every run — green but inert, masking the absence of
coverage.

It also duplicated existing coverage: the FFI <-> wasm-strategy <-> ZeroKMS
encrypt/decrypt path is already proven via AccessKeyStrategy
(wasm-round-trip/js-strategy), and the OIDC-specific getJwt -> /api/authorise
exchange is tested hermetically inside stack-auth (MockAuthServer + a
base-URL override not exposed on the published consumer API).

Keep the two contract tests — they run in CI unconditionally with no
credentials and nothing skipped — and drop the now-unused E2E block,
splitCrn helper, and encrypt/decrypt/isEncrypted imports.
@coderdan coderdan merged commit a8535c9 into chore/bump-cipherstash-stack-0.37 Jun 6, 2026
1 check passed
@coderdan coderdan deleted the test/oidc-federation-scaffold branch June 6, 2026 08:10
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.

2 participants