feat(backend): Add test session tokens endpoints#7783
feat(backend): Add test session tokens endpoints#7783
Conversation
🦋 Changeset detectedLatest commit: 2291c84 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
📝 WalkthroughWalkthroughAdds a Test Session Tokens API to the backend package: a new changeset entry; a 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@packages/backend/src/api/endpoints/TestSessionTokenApi.ts`:
- Around line 1-18: Add unit/integration tests covering the new TestSessionToken
API: write tests that call TestSessionTokenAPI.create and assert the request
shape (method 'POST', path '/test_session_tokens', and bodyParams) and that the
response is correctly deserialized into the TestSessionToken type; use the
existing AbstractAPI test harness or mock the underlying request method
(spy/stub on AbstractAPI.request) to simulate API responses and verify
deserialization and error paths. Ensure to include at least one positive test
that returns a valid TestSessionToken payload and one negative test for error
handling.
In `@packages/backend/src/api/resources/TestSessionToken.ts`:
- Around line 3-24: Add JSDoc to the public TestSessionToken class and its
constructor parameters describing each field and the expected shape, and update
the static fromJSON(TestSessionTokenJSON) method to validate the incoming object
before constructing an instance: check required keys (id, user_id, token,
status, url, created_at, updated_at), verify types (strings for
id/user_id/token/url/status and numbers for timestamps), ensure status is one of
'pending'|'accepted'|'revoked', and throw a clear error if validation fails (or
call/annotate an upstream validator if validation is guaranteed there); keep the
constructor signature and internal property names as-is (TestSessionToken,
fromJSON, TestSessionTokenJSON).
Description
Adds support for the Test Session Tokens API endpoint to the backend SDK. This allows developers to create test session tokens that can be used to impersonate users during testing or other automated flows.
Usage
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit