Skip to content

Conversation

@wassimoo
Copy link
Contributor

@wassimoo wassimoo commented Dec 11, 2025

This PoC introduces integration tests for Ory Identity session management flows, ensuring that the code examples in our documentation work correctly end-to-end.

The tests run against a test Express.js server that directly imports and uses code examples from the documentation.

While the tests use Ory's self-service API for login (via selfServiceLogin() utility), they validate the complete end-to-end flows for:

  1. Logout Flow: After authenticating via self-service API, the tests verify that the logout endpoint in the example app correctly handles session termination and redirects appropriately.

  2. Session Management Flow: Tests verify that authenticated sessions can be retrieved and validated through the example app's session endpoints.

Tests run in GitHub Actions with secrets injected for:

  • ORY_SDK_URL - Ory test account endpoint URL
  • TEST_USER_EMAIL - Test user credentials
  • TEST_USER_PASSWORD - Test user credentials

Checklist

  • I have read the contributing guidelines and signed the CLA.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability.
    If this pull request addresses a security vulnerability,
    I confirm that I got approval (please contact security@ory.com) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added the necessary documentation within the code base (if appropriate).

Further comments

@vinckr vinckr force-pushed the wassimoo/kratos-session-management-js-flow-integration-tests branch from 3729456 to 4c2f3ab Compare December 15, 2025 15:55
Copy link
Member

@zepatrik zepatrik left a comment

Choose a reason for hiding this comment

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

While the overall approach looks good, I'm thinking whether it makes more sense to have everything in one file. What you have is a bit more boilerplate (passing the SDK and exporting again), while the reader might want to have everything in one file in the end when copy-pasting. The current content is meant to be all in one file, while yours is meant to be split up. I'm pretty sure you can cut the code up into sections and only show parts of it for each code box. WDYT?

)
})
export const registerSignUpRoute = (app, ory, baseUrl) => {
app.get("/", (req, res) => {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe instead of this multi-router approach, it makes more sense to have the proper paths right here?

Suggested change
app.get("/", (req, res) => {
app.get("/signup", (req, res) => {

})

// Routers that reuse the docs sample snippets.
const signupRouter = express.Router()
Copy link
Member

Choose a reason for hiding this comment

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

And then here we would not need all these routers, but just one?

for (let cookieStr of cookieStrings) {
cookieStr = cookieStr.trim()
// Take only the name=value part (before first semicolon)
const nameValue = cookieStr.split(";")[0].trim()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check that there is at least one element before trying to access it?
Same a few lines below.

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.

4 participants