Repository navigation
feat(e2e): add TOTP support for 2FA-enabled GitHub accounts #1211
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 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ece7fde
feat(e2e): add TOTP support for 2FA-enabled GitHub accounts
ralphbean a6eb193
fix(e2e): address review findings for TOTP support
ralphbean dd72238
fix(e2e): harden TOTP handling with retry, shared helper, and race fixes
ralphbean 3ce780c
docs: add E2E_GITHUB_TOTP_SECRET to CLAUDE.md and new ADR 0039
ralphbean b8e6cea
fix(e2e): address review findings in TOTP and sudo handling
ggallen 59817bc
fix(e2e): click submit on sudo TOTP page and update ADR 0010
ggallen 87ad0d0
fix(e2e): handle select_target redirect and fix doc comment
ggallen 2b16288
fix(e2e): add TOTP fallback when sudo password fails
ggallen 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
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
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 |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| --- | ||
| title: "39. TOTP automation for e2e 2FA" | ||
| status: Accepted | ||
| relates_to: | ||
| - testing-agents | ||
| topics: | ||
| - e2e | ||
| - ci | ||
| - authentication | ||
| - 2fa | ||
| --- | ||
|
|
||
| # 39. TOTP automation for e2e 2FA | ||
|
|
||
| Date: 2026-05-19 | ||
|
|
||
| ## Status | ||
|
|
||
| Accepted | ||
|
|
||
| Extends [ADR 0010](0010-stored-session-for-e2e-browser-auth.md). | ||
|
|
||
| ## Context | ||
|
|
||
| [ADR 0010](0010-stored-session-for-e2e-browser-auth.md) established stored | ||
| Playwright sessions for e2e CI authentication. When that ADR was written, the | ||
| test account did not have 2FA enabled. With 2FA on, two new authentication | ||
| prompts appear that the existing infrastructure could not handle: | ||
|
|
||
| 1. A TOTP challenge during `make e2e-export-session` (local login). | ||
| 2. A TOTP challenge on sudo pages in CI (GitHub may present TOTP instead of | ||
| a password field for 2FA-enabled accounts). | ||
|
|
||
| ## Decision | ||
|
|
||
| Automate TOTP entry in Playwright using a shared `e2e/internal/otp` package | ||
| that wraps `pquerna/otp` to generate time-based codes. The TOTP secret is | ||
| supplied via the `E2E_GITHUB_TOTP_SECRET` environment variable (base32-encoded). | ||
|
|
||
| - `handleTOTPIfPresent()` in the login helpers detects TOTP form fields and | ||
| enters the current code. `handleSudoIfPresent()` now handles both password | ||
| and TOTP sudo prompts. | ||
| - The `export-session` command detects and completes the 2FA prompt after | ||
| password login. | ||
| - `E2E_GITHUB_TOTP_SECRET` is optional — omitting it preserves the existing | ||
| non-2FA flow. | ||
|
|
||
| ## Consequences | ||
|
|
||
| - Three repo secrets are now required in CI when the test account has 2FA: | ||
| `E2E_GITHUB_SESSION`, `E2E_GITHUB_PASSWORD`, and `E2E_GITHUB_TOTP_SECRET`. | ||
| - Session export and sudo confirmation work automatically for 2FA accounts. | ||
| - The TOTP secret is a long-lived credential that must be protected like the | ||
| password. | ||
| - If GitHub changes its TOTP form markup, the Playwright selectors will need | ||
| updating. |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.