Skip to content

Commit

Permalink
[auth-swift] Mostly unified Swift API tests (#12095)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 authored Nov 11, 2023
1 parent 3b1e6fe commit 051cc6e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions FirebaseAuth/Sources/Swift/AuthProvider/OAuthProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ import CommonCrypto
the mobile web flow is completed.
*/
@objc(getCredentialWithUIDelegate:completion:)
public func getCredentialWith(_ UIDelegate: AuthUIDelegate?,
public func getCredentialWith(_ uiDelegate: AuthUIDelegate?,
completion: ((AuthCredential?, Error?) -> Void)? = nil) {
guard let urlTypes = auth.mainBundleUrlTypes,
AuthWebUtils.isCallbackSchemeRegistered(forCustomURLScheme: callbackScheme,
Expand Down Expand Up @@ -222,7 +222,7 @@ import CommonCrypto
callbackScheme: self.callbackScheme)
}
self.auth.authURLPresenter.present(headfulLiteURL,
uiDelegate: UIDelegate,
uiDelegate: uiDelegate,
callbackMatcher: callbackMatcher) { callbackURL, error in
if let error {
callbackOnMainThread(nil, error)
Expand Down Expand Up @@ -260,9 +260,9 @@ import CommonCrypto
@return An `AuthCredential`.
*/
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 8, *)
public func credential(with UIDelegate: AuthUIDelegate?) async throws -> AuthCredential {
public func credential(with uiDelegate: AuthUIDelegate?) async throws -> AuthCredential {
return try await withCheckedThrowingContinuation { continuation in
getCredentialWith(UIDelegate) { credential, error in
getCredentialWith(uiDelegate) { credential, error in
if let credential = credential {
continuation.resume(returning: credential)
} else {
Expand Down
18 changes: 9 additions & 9 deletions FirebaseAuth/Tests/Unit/SwiftAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class AuthAPI_hOnlyTests: XCTestCase {
// Each function corresponds with a public header.
func FIRActionCodeSettings_h() {
let codeSettings = FirebaseAuth.ActionCodeSettings()
// Currently kept for backwards compatibility?
codeSettings.setIOSBundleID("abc")
codeSettings.iOSBundleID = "abc"
codeSettings.setAndroidPackageName("name", installIfNotAvailable: true, minimumVersion: "10.0")
let _: Bool = codeSettings.handleCodeInApp
Expand Down Expand Up @@ -107,10 +109,7 @@ class AuthAPI_hOnlyTests: XCTestCase {
auth.signIn(withEmail: "[email protected]", link: "link") { result, error in
}
#if os(iOS)
let provider = OAuthProvider(
providerID: GoogleAuthProvider.id,
auth: FirebaseAuth.Auth.auth()
)
let provider = OAuthProvider(providerID: "abc")
auth.signIn(with: provider, uiDelegate: nil) { result, error in
}
provider.getCredentialWith(nil) { credential, error in
Expand Down Expand Up @@ -172,15 +171,15 @@ class AuthAPI_hOnlyTests: XCTestCase {
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
func FIRAuth_hAsync() async throws {
func FIRAuth_hAsync(credential: AuthCredential) async throws {
let auth = FirebaseAuth.Auth.auth()
let user = auth.currentUser!
try await auth.updateCurrentUser(user)
_ = try await auth.fetchSignInMethods(forEmail: "[email protected]")
_ = try await auth.signIn(withEmail: "[email protected]", password: "password")
_ = try await auth.signIn(withEmail: "[email protected]", link: "link")
let provider = OAuthProvider(providerID: "abc")
#if os(iOS)
let provider = OAuthProvider(providerID: "abc")
let credential = try await provider.credential(with: nil)
_ = try await auth.signIn(with: credential)
_ = try await auth.signIn(with: OAuthProvider(providerID: "abc"), uiDelegate: nil)
Expand Down Expand Up @@ -351,8 +350,8 @@ class AuthAPI_hOnlyTests: XCTestCase {
_ = FacebookAuthProvider.credential(withAccessToken: "token")
}

#if !os(macOS) && !os(watchOS)
func FIRFedederatedAuthProvider_h() {
#if os(iOS)
func FIRFederatedAuthProvider_h() {
class FederatedAuthImplementation: NSObject, FederatedAuthProvider {
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
func credential(with UIDelegate: AuthUIDelegate?) async throws -> FirebaseAuth
Expand Down Expand Up @@ -444,6 +443,7 @@ class AuthAPI_hOnlyTests: XCTestCase {
let credential = provider.credential(withVerificationID: "id",
verificationCode: "code")
if let obj = error
// TODO: AuthErrorUserInfoMultiFactorResolverKey
.userInfo[AuthErrors.userInfoMultiFactorResolverKey] as? MultiFactorResolver {
obj.resolveSignIn(with: PhoneMultiFactorGenerator.assertion(with: credential)) { _, _ in
}
Expand Down Expand Up @@ -490,7 +490,7 @@ class AuthAPI_hOnlyTests: XCTestCase {

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
func FIROAuthProvider_h() async throws {
let provider = OAuthProvider(providerID: GoogleAuthProvider.id, auth: FirebaseAuth.Auth.auth())
let provider = OAuthProvider(providerID: "abc")
#if os(iOS)
provider.getCredentialWith(provider as? AuthUIDelegate) { credential, error in
}
Expand Down

0 comments on commit 051cc6e

Please sign in to comment.