-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Passkey swift tests #12663
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
Parent:
Passkey Support
Merged
Passkey swift tests #12663
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| import Foundation | ||
| import XCTest | ||
|
|
||
| import AuthenticationServices | ||
| import FirebaseAuth | ||
| import FirebaseCore | ||
|
|
||
|
|
@@ -109,6 +110,10 @@ class AuthAPI_hOnlyTests: XCTestCase { | |
| auth.signIn(with: OAuthProvider(providerID: "abc"), uiDelegate: nil) { result, error in | ||
| } | ||
| #endif | ||
| if #available(iOS 15.0, macOS 12.0, tvOS 16.0, *) { | ||
| auth.startPasskeySignIn { result, error in | ||
| } | ||
| } | ||
| auth.signInAnonymously { result, error in | ||
| } | ||
| auth.signIn(withCustomToken: "abc") { result, error in | ||
|
|
@@ -171,6 +176,9 @@ class AuthAPI_hOnlyTests: XCTestCase { | |
| #if os(iOS) && !targetEnvironment(macCatalyst) | ||
| try await auth.initializeRecaptchaConfig() | ||
| #endif | ||
| if #available(iOS 15.0, macOS 12.0, tvOS 16.0, *) { | ||
| _ = try await auth.startPasskeySignIn() | ||
| } | ||
| _ = try await auth.signIn(with: OAuthProvider(providerID: "abc"), uiDelegate: nil) | ||
| _ = try await auth.signInAnonymously() | ||
| _ = try await auth.signIn(withCustomToken: "abc") | ||
|
|
@@ -461,6 +469,11 @@ class AuthAPI_hOnlyTests: XCTestCase { | |
| } | ||
| #endif | ||
|
|
||
| func passkeyInfo(pi: PasskeyInfo) { | ||
| let _: String = pi.name | ||
| let _: String = pi.credentialID | ||
| } | ||
|
|
||
| func oauthCredential(credential: OAuthCredential) { | ||
| if let _: String = credential.idToken, | ||
| let _: String = credential.accessToken, | ||
|
|
@@ -583,6 +596,12 @@ class AuthAPI_hOnlyTests: XCTestCase { | |
| user.link(with: provider as! FederatedAuthProvider, uiDelegate: nil) { _, _ in | ||
| } | ||
| #endif | ||
| if #available(iOS 15.0, macOS 12.0, tvOS 16.0, *) { | ||
| user.startPasskeyEnrollment(with: "token") { _, _ in | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. finalize variation as well for the User API. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. |
||
| } | ||
| user.unenrollPasskey(with: "credentialId") { _ in | ||
| } | ||
| user.getIDTokenResult { _, _ in | ||
| } | ||
| user.getIDTokenResult(forcingRefresh: true) { _, _ in | ||
|
|
@@ -650,6 +669,10 @@ class AuthAPI_hOnlyTests: XCTestCase { | |
| try await user.reauthenticate(with: provider as! FederatedAuthProvider, uiDelegate: nil) | ||
| try await user.link(with: provider as! FederatedAuthProvider, uiDelegate: nil) | ||
| #endif | ||
| if #available(iOS 15.0, macOS 12.0, tvOS 16.0, *) { | ||
| try await user.startPasskeyEnrollment(with: "token") | ||
| } | ||
| try await user.unenrollPasskey(with: "credentialID") | ||
| _ = try await user.getIDTokenResult() | ||
| _ = try await user.getIDTokenResult(forcingRefresh: true) | ||
| _ = try await user.getIDToken() | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add
finalizePasskeySignInas well here and below.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the data type of input for finalizePasskeySignIn is ASAuthorizationPlatformPublicKeyCredentialAssertion which I did not find an initializer. Can you suggest? finalizePasskeyEnrollment is a similar story.
How this is passed to us/customers is thru a platform delegation. How did we test this with Obj-c is to mock the class and to mock the behavior when trying to access the property of the instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could pass in the ASAuthorizationPlatformPublicKeyCredentialAssertion as a parameter to the test function, since this is a build-only test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Paul. I used the with NSCoder instead, please take a look.