Skip to content
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

Adding UI Tests for MFA Flows #14213

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
8848765129D314A400780FA6 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 8848764F29D3149200780FA6 /* GoogleService-Info.plist */; };
B8431C602D03857A0093ED41 /* GoogleService-Info_multi.plist in Resources */ = {isa = PBXBuildFile; fileRef = B8431C5E2D03857A0093ED41 /* GoogleService-Info_multi.plist */; };
B8431C612D03857A0093ED41 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B8431C5F2D03857A0093ED41 /* GoogleService-Info.plist */; };
B8431C642D0385980093ED41 /* RecaptchaEnterprise in Frameworks */ = {isa = PBXBuildFile; productRef = B8431C632D0385980093ED41 /* RecaptchaEnterprise */; };
DE8B636F2BEC2DC300607B82 /* FirebaseAuth in Frameworks */ = {isa = PBXBuildFile; productRef = DE8B636E2BEC2DC300607B82 /* FirebaseAuth */; };
DE8B63722BEC2FB900607B82 /* GoogleSignIn in Frameworks */ = {isa = PBXBuildFile; productRef = DE8B63712BEC2FB900607B82 /* GoogleSignIn */; };
DE8B63742BEC2FB900607B82 /* GoogleSignInSwift in Frameworks */ = {isa = PBXBuildFile; productRef = DE8B63732BEC2FB900607B82 /* GoogleSignInSwift */; };
Expand All @@ -31,9 +33,8 @@
DE8FD4942A7D9E2700B6831A /* PhoneMultiFactorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE8FD4912A7D9D9E00B6831A /* PhoneMultiFactorTests.swift */; };
DEC2E5DD2A95331E0090260A /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEC2E5DC2A95331D0090260A /* SettingsViewController.swift */; };
DEC2E5DF2A9583CA0090260A /* AppManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEC2E5DE2A9583CA0090260A /* AppManager.swift */; };
DEC2E5E42A966DE20090260A /* GoogleService-Info_multi.plist in Resources */ = {isa = PBXBuildFile; fileRef = DEC2E5E32A966DE20090260A /* GoogleService-Info_multi.plist */; };
DED37F632AB0C4F7003A67E4 /* SettingsUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DED37F622AB0C4F7003A67E4 /* SettingsUITests.swift */; };
DEE261C52C21E9F500EECAC5 /* RecaptchaEnterprise in Frameworks */ = {isa = PBXBuildFile; productRef = DEE261C42C21E9F500EECAC5 /* RecaptchaEnterprise */; };
DEE261C52C21E9F500EECAC5 /* (null) in Frameworks */ = {isa = PBXBuildFile; };
EA02F68524A000E00079D000 /* UserActions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA02F68424A000E00079D000 /* UserActions.swift */; };
EA02F68D24A063E90079D000 /* LoginDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA02F68C24A063E90079D000 /* LoginDelegate.swift */; };
EA062D5D24A0FEB6006714D3 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = EA062D5C24A0FEB6006714D3 /* README.md */; };
Expand Down Expand Up @@ -88,7 +89,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
8848764F29D3149200780FA6 /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "GoogleService-Info.plist"; sourceTree = SOURCE_ROOT; };
B8431C5E2D03857A0093ED41 /* GoogleService-Info_multi.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info_multi.plist"; path = "../../../../../firebase-ios-auth-sample/GoogleService-Info_multi.plist"; sourceTree = "<group>"; };
B8431C5F2D03857A0093ED41 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../../../../firebase-ios-auth-sample/GoogleService-Info.plist"; sourceTree = "<group>"; };
DE4D8E1F2A8B0311001952B6 /* SwiftApplication.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = SwiftApplication.plist; sourceTree = "<group>"; };
DE8FD4682A7D660A00B6831A /* Credentials.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Credentials.swift; sourceTree = "<group>"; };
DE8FD4692A7D660A00B6831A /* AccountInfoTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountInfoTests.swift; sourceTree = "<group>"; };
Expand All @@ -110,7 +112,6 @@
DE8FD4972A7DB00600B6831A /* AuthCredentials.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuthCredentials.h; sourceTree = "<group>"; };
DEC2E5DC2A95331D0090260A /* SettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
DEC2E5DE2A9583CA0090260A /* AppManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppManager.swift; sourceTree = "<group>"; };
DEC2E5E32A966DE20090260A /* GoogleService-Info_multi.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "GoogleService-Info_multi.plist"; sourceTree = SOURCE_ROOT; };
DED37F622AB0C4F7003A67E4 /* SettingsUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsUITests.swift; sourceTree = "<group>"; };
EA02F68424A000E00079D000 /* UserActions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserActions.swift; sourceTree = "<group>"; };
EA02F68C24A063E90079D000 /* LoginDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -159,11 +160,12 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
DEE261C52C21E9F500EECAC5 /* RecaptchaEnterprise in Frameworks */,
DEE261C52C21E9F500EECAC5 /* (null) in Frameworks */,
DE8B63772BEC302200607B82 /* FacebookLogin in Frameworks */,
DE8B63742BEC2FB900607B82 /* GoogleSignInSwift in Frameworks */,
DE8B636F2BEC2DC300607B82 /* FirebaseAuth in Frameworks */,
DE8B63722BEC2FB900607B82 /* GoogleSignIn in Frameworks */,
B8431C642D0385980093ED41 /* RecaptchaEnterprise in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -308,7 +310,8 @@
EAE4CBC324855E3A00245E92 /* AuthenticationExample */ = {
isa = PBXGroup;
children = (
DEC2E5E32A966DE20090260A /* GoogleService-Info_multi.plist */,
B8431C5E2D03857A0093ED41 /* GoogleService-Info_multi.plist */,
B8431C5F2D03857A0093ED41 /* GoogleService-Info.plist */,
DE4D8E1F2A8B0311001952B6 /* SwiftApplication.plist */,
EA062D5C24A0FEB6006714D3 /* README.md */,
EA20B506249CA63300B5E581 /* AuthenticationExample.entitlements */,
Expand All @@ -319,7 +322,6 @@
EA20B47724973BB100B5E581 /* CustomViews */,
EAB3A17A2494626F00385291 /* Utility */,
EAE4CBCD24855E3D00245E92 /* Assets.xcassets */,
8848764F29D3149200780FA6 /* GoogleService-Info.plist */,
EA217894248979E200736757 /* LaunchScreen.storyboard */,
DEC2E5DE2A9583CA0090260A /* AppManager.swift */,
);
Expand Down Expand Up @@ -393,7 +395,7 @@
DE8B63712BEC2FB900607B82 /* GoogleSignIn */,
DE8B63732BEC2FB900607B82 /* GoogleSignInSwift */,
DE8B63762BEC302200607B82 /* FacebookLogin */,
DEE261C42C21E9F500EECAC5 /* RecaptchaEnterprise */,
B8431C632D0385980093ED41 /* RecaptchaEnterprise */,
);
productName = "Swifty Auth";
productReference = EAE4CBC124855E3A00245E92 /* AuthenticationExample.app */;
Expand Down Expand Up @@ -481,6 +483,7 @@
DE8B63702BEC2FB900607B82 /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */,
DE8B63752BEC302200607B82 /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */,
DE8B63782BEC342000607B82 /* XCRemoteSwiftPackageReference "gtm-session-fetcher" */,
B8431C622D0385980093ED41 /* XCRemoteSwiftPackageReference "recaptcha-enterprise-mobile-sdk" */,
);
productRefGroup = EAE4CBC224855E3A00245E92 /* Products */;
projectDirPath = "";
Expand All @@ -507,8 +510,8 @@
buildActionMask = 2147483647;
files = (
EA217895248979E200736757 /* LaunchScreen.storyboard in Resources */,
8848765129D314A400780FA6 /* GoogleService-Info.plist in Resources */,
Copy link
Contributor

Choose a reason for hiding this comment

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

the failed CI seems related to the plist file, can you revert the plist file part in this file and then try trigger CI again?

DEC2E5E42A966DE20090260A /* GoogleService-Info_multi.plist in Resources */,
B8431C602D03857A0093ED41 /* GoogleService-Info_multi.plist in Resources */,
B8431C612D03857A0093ED41 /* GoogleService-Info.plist in Resources */,
EAE4CBCE24855E3D00245E92 /* Assets.xcassets in Resources */,
EA062D5D24A0FEB6006714D3 /* README.md in Resources */,
);
Expand Down Expand Up @@ -978,6 +981,14 @@
/* End XCLocalSwiftPackageReference section */

/* Begin XCRemoteSwiftPackageReference section */
B8431C622D0385980093ED41 /* XCRemoteSwiftPackageReference "recaptcha-enterprise-mobile-sdk" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/GoogleCloudPlatform/recaptcha-enterprise-mobile-sdk";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 18.6.0;
};
};
DE8B63702BEC2FB900607B82 /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/google/GoogleSignIn-iOS.git";
Expand Down Expand Up @@ -1005,6 +1016,11 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
B8431C632D0385980093ED41 /* RecaptchaEnterprise */ = {
isa = XCSwiftPackageProductDependency;
package = B8431C622D0385980093ED41 /* XCRemoteSwiftPackageReference "recaptcha-enterprise-mobile-sdk" */;
productName = RecaptchaEnterprise;
};
DE8B636E2BEC2DC300607B82 /* FirebaseAuth */ = {
isa = XCSwiftPackageProductDependency;
productName = FirebaseAuth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,77 @@ class AuthenticationExampleUITests: XCTestCase {
)
}

func testPhoneMultiFactorEnrollUnenroll() {
// 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 = "sampleauthios"
app.textFields["Password"].tap()
app.typeText(testPassword)
// app.buttons["return"].tap() // dismiss keyboard
app.buttons["Login"].tap()
// enroll multifactor with phone
app.tabBars.buttons["Authentication"].tap()
app.tables.cells.staticTexts["Phone Enroll"].tap()
let testSecondFactorPhone = "+11234567890"
app.typeText(testSecondFactorPhone)
app.buttons["Save"].tap()
let testVerificationCode = "123456"
app.typeText(testVerificationCode)
app.buttons["Save"].tap()
let testPhoneSecondFactorDisplayName = "phone1"
app.typeText(testPhoneSecondFactorDisplayName)
app.buttons["Save"].tap()
// unenroll multifactor
app.swipeUp(velocity: .fast)
app.tables.cells.staticTexts["Multifactor unenroll"].tap()
XCTAssertTrue(app.buttons["phone1"].exists) // enrollment successful
app.buttons["phone1"].tap()
app.swipeUp(velocity: .fast)
app.tables.cells.staticTexts["Multifactor unenroll"].tap()
XCTAssertFalse(app.buttons["phone1"].exists) // unenrollment successful
app.buttons["Cancel"].tap()
// 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' as second factor
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."]
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
Loading