Skip to content

Commit 5000f90

Browse files
committed
In the system sheet, answer Google's 2-Step page with the account's authenticator code, and add inputs to run one Google attempt and only the real-backend suite
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012xYtaUjbkB1hwLtK4TEzhq
1 parent 618367b commit 5000f90

2 files changed

Lines changed: 72 additions & 21 deletions

File tree

‎.github/workflows/ios-shell.yml‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ on:
2424
workflow_dispatch:
2525
inputs:
2626
google_sign_in:
27-
description: Run the Google sign-in tests (each attempt sends a sign-in prompt to the account's phone)
27+
description: Run the Google sign-in in the system sheet (sends one sign-in prompt to the account's phone)
28+
type: boolean
29+
default: false
30+
google_sign_in_webview:
31+
description: Also run the Google sign-in in the app's web view (a second prompt)
32+
type: boolean
33+
default: false
34+
real_backend_only:
35+
description: Run only the real-backend suite (skip the mock suite, the probe and the demo)
2836
type: boolean
2937
default: false
3038

@@ -194,10 +202,14 @@ jobs:
194202
TEST_RUNNER_OPENBOT_SHELL_GOOGLE_PASSWORD: ${{ secrets.OPENBOT_SHELL_GOOGLE_PASSWORD }}
195203
TEST_RUNNER_OPENBOT_SHELL_GOOGLE_TOTP_SECRET: ${{ secrets.OPENBOT_SHELL_GOOGLE_TOTP_SECRET }}
196204
TEST_RUNNER_OPENBOT_SHELL_RUN_GOOGLE: ${{ inputs.google_sign_in }}
205+
TEST_RUNNER_OPENBOT_SHELL_RUN_GOOGLE_WEBVIEW: ${{ inputs.google_sign_in_webview }}
206+
REAL_BACKEND_ONLY: ${{ inputs.real_backend_only }}
197207
run: |
198208
export TEST_RUNNER_OPENBOT_SHELL_LATE_STACK_TRIGGER="$LATE_STACK_TRIGGER"
209+
only=()
210+
if [ "$REAL_BACKEND_ONLY" = "true" ]; then only=(-only-testing:OpenBotShellUITests/RealBackendDebugUITests); fi
199211
set -o pipefail
200-
xcodebuild test-without-building \
212+
xcodebuild test-without-building "${only[@]}" \
201213
-project ios-shell/OpenBotShell.xcodeproj \
202214
-scheme OpenBotShell \
203215
-configuration Debug \
@@ -211,7 +223,7 @@ jobs:
211223
2>&1 | tee xcodebuild.log
212224
213225
- name: Record the demo tour
214-
if: always() && steps.build.outcome == 'success'
226+
if: always() && steps.build.outcome == 'success' && inputs.real_backend_only != true
215227
timeout-minutes: 12
216228
run: |
217229
mkdir -p artifacts/video
@@ -259,6 +271,7 @@ jobs:
259271
TEST_RUNNER_OPENBOT_SHELL_GOOGLE_PASSWORD: ${{ secrets.OPENBOT_SHELL_GOOGLE_PASSWORD }}
260272
TEST_RUNNER_OPENBOT_SHELL_GOOGLE_TOTP_SECRET: ${{ secrets.OPENBOT_SHELL_GOOGLE_TOTP_SECRET }}
261273
TEST_RUNNER_OPENBOT_SHELL_RUN_GOOGLE: ${{ inputs.google_sign_in }}
274+
TEST_RUNNER_OPENBOT_SHELL_RUN_GOOGLE_WEBVIEW: ${{ inputs.google_sign_in_webview }}
262275
run: |
263276
status=0
264277
: > xcodebuild-release.log

‎ios-shell/OpenBotShellUITests/RealBackendUITests.swift‎

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ class RealBackendTestCase: ShellTestCase {
8888
let totpSecret: Data
8989
}
9090

91-
func googleInputs() throws -> GoogleInputs {
92-
guard ProcessInfo.processInfo.environment["OPENBOT_SHELL_RUN_GOOGLE"] == "true" else {
93-
throw XCTSkip("the Google sign-in runs only when the workflow is started by hand with google_sign_in: each attempt sends a sign-in prompt to the account's phone")
91+
/// `gate`: the dispatch input that must be "true" (each attempt sends a prompt to the phone).
92+
func googleInputs(gate: String = "OPENBOT_SHELL_RUN_GOOGLE") throws -> GoogleInputs {
93+
guard ProcessInfo.processInfo.environment[gate] == "true" else {
94+
throw XCTSkip("this Google sign-in runs only when the workflow is started by hand with its input on: each attempt sends a sign-in prompt to the account's phone")
9495
}
9596
let names = ["OPENBOT_SHELL_GOOGLE_EMAIL", "OPENBOT_SHELL_GOOGLE_PASSWORD", "OPENBOT_SHELL_GOOGLE_TOTP_SECRET"]
9697
note("secret-inputs: \(names.allSatisfy { secret($0) != nil } ? "present" : "absent")")
@@ -103,20 +104,25 @@ class RealBackendTestCase: ShellTestCase {
103104
return GoogleInputs(email: email, password: password, totpSecret: totpSecret)
104105
}
105106

106-
/// Google's email, password and authenticator pages, wherever they show (`roots`). One attempt.
107-
/// Stops (XCTSkip with the reason) at any CAPTCHA, "verify it's you" or other challenge: nothing
108-
/// here tries to get past one. Screenshots only before a value goes in and after the page is left.
109-
func googleSteps(app: XCUIApplication, roots: [XCUIApplication], inputs: GoogleInputs) throws {
107+
/// Google's email, password and 2-Step Verification pages, wherever they show (`roots`). One
108+
/// attempt. On the 2-Step page it answers only with the account's own authenticator code: when
109+
/// `tryAnotherWay`, it may pick that option under "Try another way" (the user decided so). It stops
110+
/// (XCTSkip with the reason) at any CAPTCHA, bot check or anything else Google asks for: nothing
111+
/// here tries to get past one. Screenshots only before a value goes in and after a page is left.
112+
func googleSteps(app: XCUIApplication, roots: [XCUIApplication], inputs: GoogleInputs, tryAnotherWay: Bool = false) throws {
110113
func live() -> [XCUIApplication] { roots.filter { $0.state != .notRunning } }
111114
func pageText() -> String {
112115
live().flatMap { labels(in: $0, limit: 200) }.joined(separator: "\n").lowercased()
113116
}
114-
func stopIfChallenged(_ step: String) throws {
117+
func stopIfChallenged(_ step: String, allowSecondStep: Bool = false) throws {
115118
let text = pageText()
116-
let signs = ["captcha", "verify it\u{2019}s you", "verify it's you", "confirm it\u{2019}s you", "confirm it's you",
117-
"unusual activity", "not a robot", "type the text you hear or see", "check your phone",
119+
var signs = ["captcha", "unusual activity", "not a robot", "type the text you hear or see",
118120
"this browser or app may not be secure", "couldn\u{2019}t sign you in", "couldn't sign you in",
119121
"try again later", "suspicious", "disallowed_useragent"]
122+
// The 2-Step Verification page itself says "verify it's you"; anywhere else that is a challenge.
123+
if !(allowSecondStep && text.contains("2-step verification")) {
124+
signs += ["verify it\u{2019}s you", "verify it's you", "confirm it\u{2019}s you", "confirm it's you", "check your phone"]
125+
}
120126
if let sign = signs.first(where: { text.contains($0) }) {
121127
screenshot("challenge-at-\(step.replacingOccurrences(of: " ", with: "-"))")
122128
note("challenged by Google at \(step) (page says '\(sign)')")
@@ -181,10 +187,36 @@ class RealBackendTestCase: ShellTestCase {
181187
submit(passwordField)
182188
sleep(10)
183189
screenshot("google-after-password")
184-
try stopIfChallenged("after password")
190+
try stopIfChallenged("after password", allowSecondStep: tryAnotherWay)
185191

186-
let text = pageText()
187-
if text.contains("authenticator") || text.contains("enter code") || text.contains("2-step verification") {
192+
var text = pageText()
193+
let codePage = { (t: String) in t.contains("google authenticator") || t.contains("authenticator app") || t.contains("enter code") }
194+
if text.contains("2-step verification") && !codePage(text) {
195+
guard tryAnotherWay else { throw XCTSkip("Google asked for its 2-Step Verification phone prompt") }
196+
let another = NSPredicate(format: "label CONTAINS[c] 'Try another way'")
197+
guard let tryAnother = first({ $0.buttons.matching(another).firstMatch }, timeout: 8)
198+
?? first({ $0.links.matching(another).firstMatch }, timeout: 2) else {
199+
screenshot("google-no-try-another-way")
200+
throw XCTSkip("the 2-Step page offered no 'Try another way'")
201+
}
202+
tryAnother.tap()
203+
sleep(6)
204+
screenshot("google-other-ways")
205+
let options = pageText()
206+
note("other ways offered: authenticator \(options.contains("authenticator")), backup codes \(options.contains("backup code")), text message \(options.contains("text message") || options.contains("sms"))")
207+
let authenticator = NSPredicate(format: "label CONTAINS[c] 'Authenticator'")
208+
guard let option = first({ $0.links.matching(authenticator).firstMatch }, timeout: 5)
209+
?? first({ $0.buttons.matching(authenticator).firstMatch }, timeout: 2)
210+
?? first({ $0.staticTexts.matching(authenticator).firstMatch }, timeout: 2) else {
211+
throw XCTSkip("the authenticator app is not among Google's other ways")
212+
}
213+
option.tap()
214+
sleep(6)
215+
screenshot("google-authenticator-page")
216+
try stopIfChallenged("authenticator page", allowSecondStep: true)
217+
text = pageText()
218+
}
219+
if codePage(text) || text.contains("2-step verification") {
188220
guard let codeField = first({ $0.webViews.textFields.firstMatch }, timeout: 10)
189221
?? first({ $0.textFields.firstMatch }, timeout: 3) else {
190222
throw XCTSkip("2-Step Verification page without a code field reachable")
@@ -194,6 +226,7 @@ class RealBackendTestCase: ShellTestCase {
194226
sleep(12)
195227
screenshot("google-after-code")
196228
try stopIfChallenged("after code")
229+
note("the authenticator code was accepted: \(!pageText().contains("wrong code") && !pageText().contains("2-step verification"))")
197230
} else {
198231
note("no authenticator page after the password")
199232
}
@@ -347,7 +380,7 @@ final class RealBackendUITests: RealBackendTestCase {
347380
/// The real sign-in with Google inside the app's web view, then (if it lets the person in) the
348381
/// whole signed-in journey in that same session, with no hook at all.
349382
func testRealGoogleSignInInWebViewAndJourney() throws {
350-
let inputs = try googleInputs()
383+
let inputs = try googleInputs(gate: "OPENBOT_SHELL_RUN_GOOGLE_WEBVIEW")
351384
try requireProduction()
352385
note("video-mark start \(Date().timeIntervalSince1970)")
353386
defer { note("video-mark end \(Date().timeIntervalSince1970)") }
@@ -412,10 +445,15 @@ final class RealBackendDebugUITests: RealBackendTestCase {
412445
google.tap()
413446
sleep(10)
414447
screenshot("2-google")
415-
try googleSteps(app: app, roots: [app, service], inputs: inputs)
416-
let landed = firstExisting([app.staticTexts.matching(NSPredicate(format: "label CONTAINS 'Start a conversation'")).firstMatch,
417-
app.textViews.firstMatch], timeout: 20) != nil
418-
note("the sheet ended on OpenBot signed in: \(landed)")
448+
try googleSteps(app: app, roots: [app, service], inputs: inputs, tryAnotherWay: true)
449+
// Production has no hand-off yet: the sheet should end on my.open.bot, signed in, inside the sheet.
450+
sleep(8)
451+
screenshot("3-where-the-sheet-ended")
452+
let home = NSPredicate(format: "label CONTAINS 'Start a conversation' OR label CONTAINS 'Ask anything'")
453+
let landed = firstExisting([app.staticTexts.matching(home).firstMatch, service.staticTexts.matching(home).firstMatch,
454+
app.textViews.matching(home).firstMatch], timeout: 20) != nil
455+
let ended = labels(in: app, limit: 200).joined(separator: "\n")
456+
note("the sheet ended on OpenBot signed in: \(landed); OpenBot sign-in page \(ended.contains("Sign in to OpenBot")); Google page \(ended.contains("Google"))")
419457
guard landed else { throw XCTSkip("Google's sign-in in the sheet did not end on OpenBot signed in") }
420458
}
421459

0 commit comments

Comments
 (0)