Extract the autofill credential resolver and cover its gating - #570
Merged
Merged
Conversation
The QuickType no-interaction path had zero tests despite carrying the auth gate and the HOTP refusal. Move the logic verbatim into an injectable AutofillOTPCredentialResolver (clock replaces raw Date()), reduce the view controller to an Outcome switch with the same indistinct ASExtensionErrors, and cover resolver and view model. Also wire the missing TestPlanReference into the VaultiOSAutofillTests scheme so its locale-pinned snapshots run correctly standalone. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
VaultCredentialProviderViewController(the autofill extension's entry point) had zero tests. Its most security-relevant decision —provideCredentialWithoutUserInteractiondeciding whether an item can be served to the QuickType bar without any user interaction — lived inline in the UIKit view controller, untestable: the auth gate viarequiresAuthenticationToCopy, the HOTP refusal (counter must not increment without UI), and an untestable directDate()for TOTP rendering.VaultAutofillViewModelwas also untested.Fix / refactor
AutofillOTPCredentialResolver: the body ofprovideOTPCredentialmoved verbatim into a small@MainActorstruct with anOutcomeenum (code/userInteractionRequired/notFound/failure), injected with a retrieval closure, the copy-action handler, and anEpochClock(replacing the rawDate()).Outcome → extensionContextswitch. The refusal paths map to exactly the same indistinctASExtensionErrors as before — no new error taxonomy leaking item properties.VaultRoot.clockinstead ofDate()(same wall clock in production).Tests
AutofillOTPCredentialResolverTests:.notFound.userInteractionRequired(the C4-relevant gate, now pinned).userInteractionRequiredTOTPAuthCode.renderCodedirectly).failureVaultAutofillViewModelTests: feature routing, dismiss publisher, blank-string filtering ontextToInsertPublisher, cancel-reason forwarding.VaultiOSAutofillTests goes from 2 tests to 15.
Also fixed en route: the
VaultiOSAutofillTestsscheme had noTestPlanReference(unlike the other test schemes), so running it standalone ignoredTestPlans/Individual/VaultiOSAutofillTests.xctestplanand the snapshot locale guard fataled on non-en_US hosts. The scheme now references its plan, matchingVaultiOSTests.Local verification: VaultiOSAutofillTests scheme green on iPhone 18 Pro Max / iOS 27.0.
🤖 Generated with Claude Code