Skip to content

Wire clearKeychain on iOS — standalone step + launchApp flag#59

Merged
omnarayan merged 1 commit intomainfrom
fix/clear-keychain
Apr 22, 2026
Merged

Wire clearKeychain on iOS — standalone step + launchApp flag#59
omnarayan merged 1 commit intomainfrom
fix/clear-keychain

Conversation

@omnarayan
Copy link
Copy Markdown
Contributor

Summary

Fixes #57. Reported by @ross-aker — thank you for the repro.

Two gaps in the WDA driver:

  1. Standalone clearKeychain step hit the default case in Execute() dispatch and errored with Step type '*flow.ClearKeychainStep' is not supported on iOS.
  2. launchApp: clearKeychain: true was silently a no-op — the struct has the field, but launchApp() never read it, so a previously-logged-in user stayed logged in even with the flag set.

Changes

  • Add clearKeychain(step) handler + shared resetKeychain() helper in pkg/driver/wda/commands.go that runs xcrun simctl keychain <udid> reset on simulators.
  • Wire *flow.ClearKeychainStep into driver.Execute() dispatch.
  • In launchApp(), fire resetKeychain() after clearState and before launch if the flag is set. Failure logs at Warn and does not abort the launch.

Real-device behavior

Returns a clear "unsupported on real iOS devices" message pointing to clearState as an alternative (reinstall drops the app's keychain entries). The iOS keychain on real devices is sandboxed per-app and can't be reset via public API without jailbreak.

Test plan

  • New test flow (standalone clearKeychain + launchApp { clearKeychain: true }) passes on iPhone 16 Pro simulator (iOS 18.6).
  • Existing iOS auth flow (login-valid-primary.yaml) still passes — no regression.
  • go build ./... + go test ./pkg/driver/wda/... green.
  • Real device: returns the expected "unsupported" message instead of a silent no-op.

Reported by @ross-aker in #57 — thank you for the clear repro.

ClearKeychainStep had no handler in the WDA driver's Execute() dispatch,
so a standalone `clearKeychain` step errored with "Step type
'*flow.ClearKeychainStep' is not supported on iOS". The launchApp
struct has a ClearKeychain field, but launchApp() never read it — so
`launchApp: clearKeychain: true` was silently a no-op: the app
relaunched with the previous user still logged in.

Fix:
- Add clearKeychain(step) handler that calls resetKeychain(), a shared
  helper that runs `xcrun simctl keychain <udid> reset` on simulators.
- Wire *flow.ClearKeychainStep into driver.Execute() so the standalone
  step works.
- In launchApp(), if step.ClearKeychain is set, invoke resetKeychain()
  after clearState and before launch. Failures log at Warn and do not
  abort the launch.

Real-device behavior: returns a clear "unsupported on real iOS devices"
result with a pointer to use `clearState` instead (reinstall drops the
app's keychain entries). The iOS keychain on real devices is sandboxed
per-app and cannot be reset via public API without jailbreak.

Verified on iPhone 16 Pro simulator (iOS 18.6): standalone clearKeychain
passes, launchApp with clearKeychain: true no longer silently no-ops,
existing auth flows still pass.

Fixes #57
@omnarayan omnarayan merged commit 0b48518 into main Apr 22, 2026
2 of 4 checks passed
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.

[BUG] clearKeychain does not work on iOS Simulator

1 participant