Skip to content

Commit

Permalink
sign in with second factor mfa test (enforce mode)
Browse files Browse the repository at this point in the history
  • Loading branch information
srushtisv committed Dec 6, 2024
1 parent 2b31a9f commit 555854c
Showing 1 changed file with 39 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class AuthenticationExampleUITests: XCTestCase {
)
}

func testPhoneMultiFactorEnrollUnenrollTest() {
func testPhoneMultiFactorEnrollUnenroll() {
// login with email password
app.staticTexts["Email & Password Login"].tap()
let testEmail = "[email protected]"
Expand All @@ -194,19 +194,19 @@ class AuthenticationExampleUITests: XCTestCase {
app.typeText(testPassword)
app.buttons["return"].tap() // Dismiss keyboard
app.buttons["Login"].tap()
// enroll with phone
// enroll multifactor with phone
app.tabBars.buttons["Authentication"].tap()
app.tables.cells.staticTexts["Phone Enroll"].tap()
let testPhone = "+11234567890"
app.typeText(testPhone)
let testSecondFactorPhone = "+11234567890"
app.typeText(testSecondFactorPhone)
app.buttons["Save"].tap()
let testVerificationCode = "123456"
app.typeText(testVerificationCode)

Check failure on line 204 in FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneMultiFactorEnrollUnenroll, Failed to synthesize event: Neither element nor any descendant has keyboard focus. Event dispatch snapshot: Application, pid: 15005, label: 'AuthenticationExample'

Check failure on line 204 in FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneMultiFactorEnrollUnenroll, Failed to synthesize event: Neither element nor any descendant has keyboard focus. Event dispatch snapshot: Application, pid: 26801, label: 'AuthenticationExample'

Check failure on line 204 in FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneMultiFactorEnrollUnenroll, Failed to synthesize event: Neither element nor any descendant has keyboard focus. Event dispatch snapshot: Application, pid: 36769, label: 'AuthenticationExample'
app.buttons["Save"].tap()
let testPhoneSecondFactorDisplayName = "phone1"
app.typeText(testPhoneSecondFactorDisplayName)
app.buttons["Save"].tap()
// unenroll
// unenroll multifactor
app.swipeUp(velocity: .fast)
app.tables.cells.staticTexts["Multifactor unenroll"].tap()
XCTAssertTrue(app.buttons["phone1"].exists) // enrollment successful
Expand All @@ -215,11 +215,44 @@ class AuthenticationExampleUITests: XCTestCase {
app.tables.cells.staticTexts["Multifactor unenroll"].tap()
XCTAssertFalse(app.buttons["phone1"].exists) // unenrollment successful
app.buttons["Cancel"].tap()
// Sign out explicitly after unenroll
// Sign out after unenroll
app.tabBars.buttons["Current User"].tap()
app.tabBars.firstMatch.buttons.element(boundBy: 1).tap()
}

func testPhoneSecondFactorSignIn() {
// login with email password
app.staticTexts["Email & Password Login"].tap()
let testEmail = "[email protected]"
app.textFields["Email"].tap()
app.typeText(testEmail)
app.buttons["return"].tap() // Dismiss keyboard
let testPassword = "sampleios123"
app.textFields["Password"].tap()
app.typeText(testPassword)
app.buttons["return"].tap() // Dismiss keyboard
app.buttons["Login"].tap()
// login with second factor
XCTAssertTrue(app.staticTexts["Choose a second factor to continue."].waitForExistence(timeout: 5))
let secondFactor = app.staticTexts["phone2"] // Select 'phone2' from the modal list
XCTAssertTrue(secondFactor.exists, "'phone2' option should be visible in the modal.")
secondFactor.tap()
app.buttons["Send Verification Code"].tap()
let verificationCodeInput = app.textFields["Enter verification code."]
XCTAssertTrue(verificationCodeInput.waitForExistence(timeout: 2), "OTP input field should appear.") // Wait for the OTP input field to appear

Check failure on line 242 in FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneSecondFactorSignIn, XCTAssertTrue failed - OTP input field should appear.

Check failure on line 242 in FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneSecondFactorSignIn, XCTAssertTrue failed - OTP input field should appear.

Check failure on line 242 in FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneSecondFactorSignIn, XCTAssertTrue failed - OTP input field should appear.
verificationCodeInput.tap()
let testVerificationCode = "123456"
verificationCodeInput.typeText(testVerificationCode)
let signInButton = app.buttons["Sign in"]
XCTAssertTrue(signInButton.waitForExistence(timeout: 2), "'Sign in' button should be visible.")
signInButton.tap()
// sign out
let signOutButton = app.buttons["Sign Out"]
if signOutButton.exists {
signOutButton.tap()
}
}

func DRAFT_testGoogleSignInAndLinkAccount() {
let interruptionMonitor = addUIInterruptionMonitor(withDescription: "Sign in with Google") {
alert -> Bool in
Expand Down

0 comments on commit 555854c

Please sign in to comment.