Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-12]
os: [macos-13]
podspec: [GoogleSignIn.podspec, GoogleSignInSwiftSupport.podspec]
flag: [
"",
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
- sdk: 'macosx'
destination: '"platform=OS X,arch=x86_64"'
- sdk: 'iphonesimulator'
destination: '"platform=iOS Simulator,name=iPhone 14"'
destination: '"platform=iOS Simulator,name=iPhone 15"'
steps:
- uses: actions/checkout@v3
- name: Build unit test target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ - (void)verifyAccountDetailsInteractivelyWithOptions:(GIDSignInInternalOptions *
return;
}

[self assertValidCurrentUser];

// Explicitly throw exception for missing client ID here. This must come before
// scheme check because schemes rely on reverse client IDs.
[self assertValidParameters:options];
Expand Down Expand Up @@ -231,15 +229,6 @@ - (void)processAuthorizationResponse:(OIDAuthorizationResponse *)authorizationRe

#pragma mark - Helpers

// Assert that a current user exists.
- (void)assertValidCurrentUser {
if (!GIDSignIn.sharedInstance.currentUser) {
// NOLINTNEXTLINE(google-objc-avoid-throwing-exception)
[NSException raise:NSInvalidArgumentException
format:@"|currentUser| must be set to verify."];
}
}

// Asserts the parameters being valid.
- (void)assertValidParameters:(GIDSignInInternalOptions *)options {
if (![options.configuration.clientID length]) {
Expand Down
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ let package = Package(
name: "GoogleSignIn",
dependencies: [
.product(name: "AppAuth", package: "AppAuth"),
.product(name: "AppAuthCore", package: "AppAuth"),
.product(name: "AppCheckCore", package: "AppCheck"),
.product(name: "GTMAppAuth", package: "GTMAppAuth"),
.product(name: "GTMSessionFetcherCore", package: "GTMSessionFetcher"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,33 @@ class DaysUntilBirthdayUITests_iOS: XCTestCase {
private let signInDisclaimerHeaderText =
"Sign in to Days Until Birthday"
private let additionalAccessHeaderText = "Days Until Birthday wants additional access to your Google Account"
private let infoSharingHeaderText = "Share some info with Days Until Birthday"
private let appTrustWarningText = "Make sure you trust Days Until Birthday"
private let chooseAnAccountHeaderText = "Choose an account"
private let notNowText = "Not Now"
private let timeout: TimeInterval = 5
private let timeout: TimeInterval = 30

private let sampleApp = XCUIApplication()
private let springboardApp = XCUIApplication(
bundleIdentifier: "com.apple.springboard"
)

func testSignInFetchVerificationSignalAndDisconnect() {
sampleApp.launch()
XCTAssertTrue(signIn())
XCTAssertTrue(navigateToVerifyMyAge())

XCTAssertTrue(navigateBackToUserProfileView())

sampleApp.navigationBars.buttons["Disconnect"].tap()

guard sampleApp
.buttons["GoogleSignInButton"]
.waitForExistence(timeout: timeout) else {
return XCTFail("Disconnecting should return user to sign in view")
}
}

func testSignInNavigateToDaysUntilBirthdayAndDisconnect() {
sampleApp.launch()

Expand Down Expand Up @@ -195,6 +212,75 @@ extension DaysUntilBirthdayUITests_iOS {
return true
}

func navigateToVerifyMyAge() -> Bool {
guard sampleApp.buttons["Verify My Age"]
.waitForExistence(timeout: timeout) else {
XCTFail("Failed to find button navigating to verify my age view")
return false
}
sampleApp.buttons["Verify My Age"].tap()

if springboardApp
.staticTexts[signInStaticText]
.waitForExistence(timeout: timeout) {
guard springboardApp
.buttons["Continue"]
.waitForExistence(timeout: timeout) else {
XCTFail("Failed to find 'Continue' button")
return false
}
springboardApp.buttons["Continue"].tap()

if sampleApp
.staticTexts[chooseAnAccountHeaderText]
.waitForExistence(timeout: timeout) {
guard findAndTapExistingSignedInEmail() else {
XCTFail("Failed to find signed-in account")
return false
}
}

handleInfoSharingRequestIfNeeded()
}

guard sampleApp.staticTexts["Verified Account!"]
.waitForExistence(timeout: 30) else {
XCTFail("Failed to show age verification view")
return false
}

let currentAccessTokenIdentifier = sampleApp.staticTexts["Access Token:"]

guard currentAccessTokenIdentifier.waitForExistence(timeout: timeout) else {
XCTFail("Access Token element did not appear")
return false
}

guard sampleApp.buttons["Fetch Age Verification Signal"]
.waitForExistence(timeout: timeout) else {
XCTFail("Failed to find button to refresh access token")
return false
}
sampleApp.buttons["Fetch Age Verification Signal"].tap()

guard sampleApp.staticTexts["User is verified over 18!"]
.waitForExistence(timeout: 30) else {
XCTFail("Failed to show age verification signal view")
return false
}

guard sampleApp
.navigationBars
.buttons["Close"]
.waitForExistence(timeout: timeout) else {
XCTFail("Failed to show close button back to age signal view")
return false
}
sampleApp.navigationBars.buttons["Close"].tap()

return true
}

/// Navigates to the days until birthday view from the user profile view.
/// - returns: `true` if the navigation was performed successfully.
/// - note: This method will attempt to find a pop up asking for permission to
Expand Down Expand Up @@ -262,6 +348,17 @@ extension DaysUntilBirthdayUITests_iOS {
return true
}

func handleInfoSharingRequestIfNeeded(){
let currentlyShowingInfoSharingRequest = sampleApp.staticTexts[infoSharingHeaderText]
.waitForExistence(timeout: timeout) &&
sampleApp.buttons["Agree"]
.waitForExistence(timeout: timeout)

if currentlyShowingInfoSharingRequest {
sampleApp.buttons["Agree"].tap()
}
}

/// Proceeds through the view with header "Days Until Birthday wants additional access to your Google Account" if needed.
func handleAccessRequestIfNeeded() {
let currentlyShowingAdditionalAccessRequest = sampleApp.staticTexts[additionalAccessHeaderText]
Expand Down