Skip to content

fix(integration-tests): isolate user data per test run#41

Merged
lucasloisp merged 1 commit into
nextfrom
llois-c/fix-integration-test-user-isolation
May 14, 2026
Merged

fix(integration-tests): isolate user data per test run#41
lucasloisp merged 1 commit into
nextfrom
llois-c/fix-integration-test-user-isolation

Conversation

@lucasloisp
Copy link
Copy Markdown
Collaborator

Summary

  • Generate a unique custom-auth subject per test instance instead of reusing a static JWT_AUTH_SUBJECT (default java-sdk-sub-id)
  • Add jwt_auth_user helper that lazily creates a fresh Privy user via users.create with a custom_auth linked account
  • generate_test_jwt now ensures the user exists before signing, since downstream endpoints (e.g. /wallets/authenticate) reject JWTs for unknown subjects
  • JWT exchange tests provision a wallet for the user upfront — /wallets/authenticate requires the user to own a wallet; the old shared user worked only because it had wallets accumulated from past runs

Why

Each integration run added wallets under the same shared user, eventually tripping the per-user wallet limit (e.g. User has reached a maximum limit of 100 tron wallets). A fresh user per test means every run starts clean.

Test plan

  • bundle exec rake test:integration passes twice in succession (verifies fresh data per run)
  • bundle exec rake test passes
  • bundle exec rake lint passes

## Summary
- Generate a unique custom-auth subject per test instance instead of reusing a static `JWT_AUTH_SUBJECT` (default `java-sdk-sub-id`)
- Add `jwt_auth_user` helper that lazily creates a fresh Privy user via `users.create` with a `custom_auth` linked account
- `generate_test_jwt` now ensures the user exists before signing, since downstream endpoints (e.g. `/wallets/authenticate`) reject JWTs for unknown subjects
- JWT exchange tests provision a wallet for the user upfront — `/wallets/authenticate` requires the user to own a wallet; the old shared user worked only because it had wallets accumulated from past runs

## Why
Each integration run added wallets under the same shared user, eventually tripping the per-user wallet limit (e.g. `User has reached a maximum limit of 100 tron wallets`). A fresh user per test means every run starts clean.

## Test plan
- [x] `bundle exec rake test:integration` passes twice in succession (verifies fresh data per run)
- [x] `bundle exec rake test` passes
- [x] `bundle exec rake lint` passes
@lucasloisp lucasloisp requested a review from jagtejsodhi May 14, 2026 16:29
Copy link
Copy Markdown
Collaborator Author

lucasloisp commented May 14, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@lucasloisp lucasloisp marked this pull request as ready for review May 14, 2026 16:29
@lucasloisp lucasloisp merged commit a6ae14b into next May 14, 2026
14 checks passed
@stainless-app stainless-app Bot mentioned this pull request May 14, 2026
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