- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.7k
 
Adding Integration Test for Phone Number Authentication in Firebase #13538
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
          
     Closed
      
      
    
  
     Closed
                    Changes from 12 commits
      Commits
    
    
            Show all changes
          
          
            21 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      bde0a72
              
                Adding Test for Phone Number Authentication in Firebase
              
              
                srushtisv d6d2000
              
                lint fixes
              
              
                pragatimodi a87afc7
              
                adding Google copyrights
              
              
                srushtisv be9d56e
              
                Switch CI for Auth Tests to Main firebase-ios-sdk Repo
              
              
                srushtisv 33ee698
              
                lint fixes
              
              
                srushtisv dfb77a7
              
                lint fixes
              
              
                srushtisv 8af5304
              
                lint fixes
              
              
                srushtisv 1dde83b
              
                fixes
              
              
                srushtisv 3dcb19a
              
                modified test phone number for phoneAuthTest
              
              
                srushtisv 9b805b2
              
                fixes
              
              
                srushtisv 8b91307
              
                updated project.pbxproj file from suggestions
              
              
                srushtisv 4407853
              
                applying suggestions from code review
              
              
                srushtisv 79430a2
              
                Updated from code review
              
              
                srushtisv a088d82
              
                Added test for async variation
              
              
                srushtisv 35f5b2f
              
                add expectations to callbacks fns
              
              
                pragatimodi d32b320
              
                add
              
              
                pragatimodi bcfa862
              
                lint
              
              
                pragatimodi 3717629
              
                change force refresh value
              
              
                pragatimodi 88ac589
              
                remove async implementations
              
              
                pragatimodi 7f080a2
              
                Merge remote-tracking branch 'refs/remotes/origin/phone-auth-login'
              
              
                srushtisv 542b248
              
                Merge remote-tracking branch 'refs/remotes/origin/rce-phone-tests'
              
              
                srushtisv 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
    
  
  
    
              
              
        
          
          
            63 changes: 63 additions & 0 deletions
          
          63 
        
  FirebaseAuth/Tests/SampleSwift/SwiftApiTests/PhoneAuthTest.swift
  
  
      
      
   
        
      
      
    
  
    
      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 | 
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Copyright 2024 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| 
     | 
||
| import FirebaseAuth | ||
| import Foundation | ||
| import XCTest | ||
| 
     | 
||
| class PhoneAuthTests: TestsBase { | ||
| let phoneNumber = "+12345678910" | ||
| // This test verification code is specified for the given test phone number in the developer | ||
| // console. | ||
| let verificationCode = "123456" | ||
| 
     | 
||
| func testSignInWithPhoneNumber() throws { | ||
| Auth.auth().settings?.isAppVerificationDisabledForTesting = true | ||
| let auth = Auth.auth() | ||
| let expectation = self.expectation(description: "Sign in with phone number") | ||
| 
     | 
||
| // PhoneAuthProvider used to initiate the Verification process and obtain a verificationID. | ||
| PhoneAuthProvider.provider() | ||
| .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") | ||
| } | ||
| 
     | 
||
| // Create a credential using the test verification code. | ||
| let credential = PhoneAuthProvider.provider().credential( | ||
| withVerificationID: verificationID ?? "", | ||
| verificationCode: self.verificationCode | ||
| ) | ||
| // 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.phoneNumber, | ||
| "Phone number does not match" | ||
| ) | ||
| } | ||
| expectation.fulfill() | ||
| } | ||
| } | ||
| 
     | 
||
| waitForExpectations(timeout: TestsBase.kExpectationsTimeout) | ||
| } | ||
| } | 
  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.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.