Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cache sessions for multiple users #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lukevmorris
Copy link

@lukevmorris lukevmorris commented Mar 23, 2022

Description

Closes #25

Serve encrypted sessions directly from an in-memory cache, performing a full login when necessary on a cache miss. This should happen only once for each user in a test run, alleviating some pressure on the Auth0 API, particularly in CI environments where multiple copies of the suite may run in parallel.

How to test

The Cypress terminal window will output http logs indicating that a programmatic login has occurred:

POST /oauth/token 200 978.683 ms - -
GET /userinfo 200 409.344 ms - -

I simply ran my Cypress suite of 40 tests against both this branch and main, and counted how many times these log entries appeared. On main, I saw 22 instances. On this branch, I saw 9 -- one for each user in the test suite -- without any loss in functionality.

One thing to note: if any test updates the Cypress superdomain, it seems that the Cypress window is reset and the cache is lost. I'm curious if there's another way to store the cache such that it persists across superdomain updates.

@@ -1,53 +1,46 @@
let cachedUsername;
Copy link
Author

Choose a reason for hiding this comment

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

I am not sure this variable was ever set, so I removed it and everything consuming it. I believe the sessionStore is an expansion of its intended behavior.

@sir-dunxalot
Copy link
Owner

Thank you @lukevmorris!

Regarding Cypress superdomain, that's a good call out. I guess my question is how likely it is that the superdomain changes. Per this security documentation the superdomain can't change during a test. I'm OK not supporting the use case of the superdomain changing between tests for now (assuming someone can open an issue if they need that use case supported).

I just ran the test suite and tests are failing but the error seems unrelated to this PR. @natterstefan do you have any insight into why the Github actions test might be failing here?

@lukevmorris
Copy link
Author

I'm OK not supporting the use case of the superdomain changing between tests for now

Sounds like a plan! Let me know if I can help at all with the failing tests.

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.

The login command will always "choose to relog" and remove cookies
2 participants