feat(core): add test_accounts_captcha for staging CAPTCHA bypass#454
feat(core): add test_accounts_captcha for staging CAPTCHA bypass#454blink-claw-bot wants to merge 2 commits intoblinkbitcoin:mainfrom
Conversation
Allows specific phone numbers (configured in galoy.yaml) to bypass Geetest CAPTCHA validation. Enables automated agents to authenticate on staging without solving challenges. Changes: - Add test_accounts_captcha config option (schema + types + yaml parser) - Skip CAPTCHA in requestPhoneCodeWithCaptcha when phone is in list - Add logging and tracing when CAPTCHA is skipped - Integration tests with mocked dependencies verify bypass logic - Unit tests for config parsing Recreates blinkbitcoin#417 (reverted in blinkbitcoin#424) with: - No quickstart changes (auto-generated) - No unrelated dependency bumps - Proper integration tests with mocking
Commit overviewRecreates #417 (reverted in #424) with proper testing and no quickstart changes. Core changes
Tests (267 lines)Unit test (
Integration test (
What's different from #417
|
There was a problem hiding this comment.
Pull request overview
Adds a staging-oriented configuration option to bypass Geetest CAPTCHA for a controlled set of test phone numbers, enabling automated authentication flows (CI/agents) without weakening rate limiting or other checks.
Changes:
- Introduces
test_accounts_captchain YAML config + JSON schema/type definitions. - Adds
getTestAccountsCaptcha()config accessor. - Updates
requestPhoneCodeWithCaptcha()to skip Geetest validation for configured test phones, with logging + tracing. - Adds unit and mocked integration-style tests covering bypass and non-bypass flows.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| core/api/galoy.yaml | Adds test_accounts_captcha: [] to default config. |
| core/api/src/config/schema.ts | Extends config JSON schema to validate/default the new setting. |
| core/api/src/config/schema.types.d.ts | Extends YamlSchema typing with test_accounts_captcha. |
| core/api/src/config/yaml.ts | Adds getTestAccountsCaptcha() accessor. |
| core/api/src/app/authentication/request-code.ts | Skips Geetest validation for configured test phones; adds log + tracing attribute. |
| core/api/test/unit/app/auth/test-accounts-captcha.spec.ts | Unit tests for getTestAccountsCaptcha() parsing behavior. |
| core/api/test/unit/app/auth/request-code-captcha-bypass.spec.ts | Mocked integration-style tests for bypass behavior and normal CAPTCHA flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,225 @@ | |||
| import { CaptchaUserFailToPassError } from "@/domain/captcha/errors" | |||
|
|
|||
| // Mock functions declared at module scope — jest.fn() calls are hoisted. | |||
There was a problem hiding this comment.
The comment about hoisting is misleading: Jest hoists jest.mock() calls, but jest.fn() declarations are not hoisted. Consider rewording to avoid confusion (e.g., explain that the mock factory is hoisted and therefore must not reference later-initialized variables).
| // Mock functions declared at module scope — jest.fn() calls are hoisted. | |
| // Mock functions declared at module scope so hoisted jest.mock() factories can reference them. |
Collapse multiline arrays to single line to stay within printWidth 90.
Commit
|
|
why do you need this? for staging or local env? |
|
For staging — it lets CI and automated agents (like me) authenticate without solving Geetest CAPTCHAs. The config only applies to explicitly listed test phone numbers, so production is unaffected. The use case: we run automated E2E tests and need to log in to staging accounts programmatically. Without this, every auth flow hits the CAPTCHA wall. |
Summary
Adds a
test_accounts_captchaconfig option togaloy.yamlthat allows specific phone numbers to bypass Geetest CAPTCHA validation inrequestPhoneCodeWithCaptcha(). This enables automated agents and CI pipelines to authenticate on staging without solving CAPTCHA challenges.Background
This recreates the functionality from PR #417 (merged then reverted in #424). The revert was due to:
What is different this time
core/api/files are modifiedpackage.jsonorpnpm-lock.yamlchangesgetTestAccountsCaptcha()config parsing (3 tests)requestPhoneCodeWithCaptcha()behavior (7 tests):test_accounts_captcha(Geetest.validate NOT called)test_accounts_captchaarray means normal CAPTCHA flowChanges
core/api/galoy.yaml— Addtest_accounts_captcha: []configcore/api/src/config/schema.ts— Add JSON schema fortest_accounts_captchacore/api/src/config/schema.types.d.ts— Add TypeScript typecore/api/src/config/yaml.ts— AddgetTestAccountsCaptcha()functioncore/api/src/app/authentication/request-code.ts— Checktest_accounts_captchabefore Geetest validationcore/api/test/unit/app/auth/test-accounts-captcha.spec.ts— Unit tests for config parsingcore/api/test/unit/app/auth/request-code-captcha-bypass.spec.ts— Mocked integration tests for bypass logicHow it works
In
requestPhoneCodeWithCaptcha(), before calling Geetest CAPTCHA validation, the function checks if the phone number exists intest_accounts_captcha. If it does:baseLogger.info)requestCode.captchaSkipped: true)