Skip to content

Commit

Permalink
added test phone number from sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
srushtisv committed Aug 29, 2024
1 parent 1dde83b commit 66252e9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>558150562999-qmutin4jbpcs78t2p68jj95qt2k9q9cs.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.558150562999-qmutin4jbpcs78t2p68jj95qt2k9q9cs</string>
<key>API_KEY</key>
<string>AIzaSyD3Y3EiFWFmtagF9Y_VGWOa71GiAf9SJtA</string>
<key>GCM_SENDER_ID</key>
<string>558150562999</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.google.firebaseAuthSDKSampleApp.dev</string>
<key>PROJECT_ID</key>
<string>fir-ios-auth-sample</string>
<key>STORAGE_BUCKET</key>
<string>fir-ios-auth-sample.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:558150562999:ios:b7a8bbf5fad1845d2cc932</string>
</dict>
</plist>
15 changes: 6 additions & 9 deletions FirebaseAuth/Tests/SampleSwift/SwiftApiTests/PhoneAuthTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// PhoneAuthTest.swift
// SwiftApiTests

import FirebaseAuth
import Foundation
import XCTest

class PhoneAuthTests: TestsBase {
let kPhoneNumber = "+19999999999"
let phoneNumber = "+12345678910"
// This test verification code is specified for the given test phone number in the developer
// console.
let kVerificationCode = "777777"
let verificationCode = "123456"

func testSignInWithPhoneNumber() throws {
Auth.auth().settings?.isAppVerificationDisabledForTesting = true // toAdd
Expand All @@ -33,7 +31,7 @@ class PhoneAuthTests: TestsBase {

// PhoneAuthProvider used to initiate the Verification process and obtain a verificationID.
PhoneAuthProvider.provider()
.verifyPhoneNumber(kPhoneNumber, uiDelegate: nil) { verificationID, error in
.verifyPhoneNumber(phoneNumber, uiDelegate: nil) { verificationID, error in
if let error {
XCTAssertNil(error, "Verification error should be nil")
XCTAssertNotNil(verificationID, "Verification ID should not be nil")
Expand All @@ -42,17 +40,17 @@ class PhoneAuthTests: TestsBase {
// Create a credential using the test verification code.
let credential = PhoneAuthProvider.provider().credential(
withVerificationID: verificationID ?? "",
verificationCode: self.kVerificationCode
verificationCode: self.verificationCode
)
// signs in using the credential and verifies that the user is signed in correctly by
// Signs in using the credential and verifies that the user is signed in correctly by
// checking auth.currentUser.
auth.signIn(with: credential) { authResult, error in
if let error {
XCTAssertNil(error, "Sign in error should be nil")
XCTAssertNotNil(authResult, "AuthResult should not be nil")
XCTAssertEqual(
auth.currentUser?.phoneNumber,
self.kPhoneNumber,
self.phoneNumber,
"Phone number does not match"
)
}
Expand All @@ -61,6 +59,5 @@ class PhoneAuthTests: TestsBase {
}

waitForExpectations(timeout: TestsBase.kExpectationsTimeout)
// deleteCurrentUser()
}
}

0 comments on commit 66252e9

Please sign in to comment.