diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 0c0536cf..19e75f5e 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-12] + os: [macos-13] podspec: [GoogleSignIn.podspec, GoogleSignInSwiftSupport.podspec] flag: [ "", @@ -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 diff --git a/GoogleSignIn/Sources/GIDVerifyAccountDetail/Implementations/GIDVerifyAccountDetail.m b/GoogleSignIn/Sources/GIDVerifyAccountDetail/Implementations/GIDVerifyAccountDetail.m index 51bacc69..7ff865f4 100644 --- a/GoogleSignIn/Sources/GIDVerifyAccountDetail/Implementations/GIDVerifyAccountDetail.m +++ b/GoogleSignIn/Sources/GIDVerifyAccountDetail/Implementations/GIDVerifyAccountDetail.m @@ -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]; @@ -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]) { diff --git a/Package.swift b/Package.swift index 95ccaaf2..4561e912 100644 --- a/Package.swift +++ b/Package.swift @@ -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"), diff --git a/Samples/Swift/DaysUntilBirthday/DaysUntilBirthdayUITests(iOS)/DaysUntilBirthdayUITests_iOS.swift b/Samples/Swift/DaysUntilBirthday/DaysUntilBirthdayUITests(iOS)/DaysUntilBirthdayUITests_iOS.swift index 7d05239f..7ec038f7 100644 --- a/Samples/Swift/DaysUntilBirthday/DaysUntilBirthdayUITests(iOS)/DaysUntilBirthdayUITests_iOS.swift +++ b/Samples/Swift/DaysUntilBirthday/DaysUntilBirthdayUITests(iOS)/DaysUntilBirthdayUITests_iOS.swift @@ -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() @@ -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 @@ -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]