Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions FirebaseAuth/Tests/Unit/SwiftAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import Foundation
import XCTest

import AuthenticationServices
import FirebaseAuth
import FirebaseCore

Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add finalizePasskeySignIn as well here and below.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

}
}
auth.signInAnonymously { result, error in
}
auth.signIn(withCustomToken: "abc") { result, error in
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finalize variation as well for the User API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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()
Expand Down