-
Notifications
You must be signed in to change notification settings - Fork 3
Add authentication to load tests #3246
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cefc778
Update auth setup
rhysyngsun 4b08dc8
Latest
rhysyngsun 4d6168a
Escape regex input
rhysyngsun b52365e
Fixes
rhysyngsun eee78e8
Latest
rhysyngsun 092584b
bot feedback
rhysyngsun 39b4811
Fix readme
rhysyngsun 2fe13dd
Addressing some feedback
rhysyngsun 520a54c
Feedback
rhysyngsun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,3 +147,5 @@ backups/ | |
| /playwright/.cache/ | ||
|
|
||
| .claude | ||
|
|
||
| load_testing/data/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,45 @@ | ||
| import { SharedArray } from "k6/data" | ||
|
|
||
| export function getAccessToken(): String { | ||
| export type AuthCredential = { | ||
| email: string | ||
| password: string | ||
| } | ||
|
|
||
| export function getAccessToken(): string | null { | ||
| return __ENV.AUTH_ACCESS_TOKEN | ||
| } | ||
|
|
||
| export const users = new SharedArray("users", function () { | ||
| if (!__ENV.USERS_JSON_FILE) { | ||
| return [] | ||
| export function hasAccessToken(): boolean { | ||
| return !!getAccessToken() | ||
| } | ||
|
|
||
| function _validate_credentials(credentials) { | ||
| if (!Array.isArray(credentials)) { | ||
| throw Error("Expected an array of credentials") | ||
| } | ||
|
|
||
| for (let index = 0; index < credentials.length; index++) { | ||
| const credential = credentials[index] | ||
| if (!Object.hasOwn(credential, "email")) { | ||
| throw Error(`User entry is missing 'email' at index ${index}`) | ||
| } | ||
| if (!Object.hasOwn(credential, "password")) { | ||
| throw Error(`User entry is missing 'password' at index ${index}`) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export const credentials: AuthCredential[] = new SharedArray( | ||
| "credentials", | ||
| function () { | ||
| if (!__ENV.USERS_JSON_FILE) { | ||
| return [] | ||
| } | ||
|
|
||
| const parsed = JSON.parse(open(__ENV.USERS_JSON_FILE)) | ||
|
|
||
| _validate_credentials(parsed) | ||
|
|
||
| return JSON.parse(open(__ENV.USERS_JSON_FILE)) | ||
| }) | ||
| return parsed | ||
| }, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,20 @@ | ||
| import { NewBrowserContextOptions } from "k6/browser" | ||
|
|
||
| export const BACKEND_BASE_URL: string = __ENV.BACKEND_BASE_URL | ||
| export const FRONTEND_BASE_URL: string = __ENV.FRONTEND_BASE_URL | ||
| export const BACKEND_BASE_URL: string = __ENV.BACKEND_BASE_URL?.replace( | ||
| /\/$/, | ||
| "", | ||
| ) | ||
| export const FRONTEND_BASE_URL: string = __ENV.FRONTEND_BASE_URL?.replace( | ||
| /\/$/, | ||
| "", | ||
| ) | ||
| export const SSO_BASE_URL: string = ( | ||
| __ENV.SSO_BASE_URL ?? "http://localhost" | ||
| ).replace(/\/$/, "") | ||
|
|
||
| export const IGNORE_HTTPS_ERRORS: boolean = | ||
| (__ENV.IGNORE_HTTPS_ERRORS || "false").toLowerCase() == "true" | ||
|
|
||
| export const BROWSER_CONTEXT_OPTIONS: NewBrowserContextOptions = { | ||
| ignoreHTTPSErrors: Object.hasOwn(__ENV, "BROWSER_IGNORE_HTTPS_ERRORS") | ||
| ? __ENV.BROWSER_IGNORE_HTTPS_ERRORS | ||
| : false, | ||
| ignoreHTTPSErrors: IGNORE_HTTPS_ERRORS, | ||
| } |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Race condition + multi-element matcher. The
data-testidmounts immediately as an empty wrapper; article children only appear after React Query resolves, socount()reads0and.nth(0).click()then hangs ~30s on a missing element. Also, the home page renders severalResourceCarouselinstances —getByTestIdmatches them all; scope to first.