Skip to content

feat(appcheck): implement RecaptchaEnterpriseProvider and tests#16155

Open
ncooke3 wants to merge 62 commits into
mainfrom
nc/recaptcha-1
Open

feat(appcheck): implement RecaptchaEnterpriseProvider and tests#16155
ncooke3 wants to merge 62 commits into
mainfrom
nc/recaptcha-1

Conversation

@ncooke3

@ncooke3 ncooke3 commented May 4, 2026

Copy link
Copy Markdown
Member

Add reCAPTCHA Enterprise Provider to Firebase App Check

Metadata

Description

This PR integrates the RecaptchaEnterpriseProvider into the Firebase App Check SDK within this repository. It provides the Objective-C wrapper implementation (FIRRecaptchaEnterpriseProvider), a factory for it, and significant updates to the test app to support automated E2E testing. It also updates CI workflows and Package.swift to allow testing against specific branches of the app-check dependency.

Test App & E2E Testing

Significant updates were made to FIRAppCheckTestApp to enable robust E2E testing:

  • Configurability: Providers can now be selected and configured via environment variables (APP_CHECK_PROVIDER, RECAPTCHA_SITE_KEY) passed to the test runner.
  • E2E Tests: Added a new test target with tests verifying token acquisition, caching, forced refresh, and actual access to Firebase Storage protected by App Check.
  • Documentation: Added E2E_TESTING.md detailing how to configure and run these tests locally.

Dependencies

  • Updated Package.swift to support resolving the app-check dependency from a local path or a specific branch via environment variables (FIREBASE_APP_CHECK_LOCAL_PATH, FIREBASE_APP_CHECK_BRANCH).
  • Added dependency on the new RecaptchaEnterpriseProvider product from the app-check package.
  • Added FirebaseStorage to the test app to verify end-to-end flows with a Firebase service.

New APIs

  • FIRRecaptchaEnterpriseProvider
  • FIRAppCheckRecaptchaEnterpriseProviderFactory

CI & Build Workflow

  • Updated .github/workflows/_spm.yml to support injecting custom environment variables (via JSON) into the GitHub Actions environment.
  • Configured .github/workflows/sdk.appcheck.yml to use the nc/target-split branch of the app-check repo for testing.
  • Updated scripts/build.sh to use python3 instead of python for log exporting.

Tests Added

  • Unit Tests (FirebaseAppCheck/Tests/Unit/RecaptchaProvider):
    • FIRRecaptchaEnterpriseProviderTests: Mocks the underlying core provider to verify success and failure completion paths.
    • FIRRecaptchaEnterpriseProviderFactoryTests: Verifies the factory correctly instantiates the provider.
  • E2E Tests (FIRAppCheckTestAppTests):
    • Verifies the full flow from token acquisition to usage with Firebase Storage on a simulator.

Other Changes

  • Updated CHANGELOG.md to note the addition of the reCAPTCHA Enterprise provider.
  • Added new log message codes in FIRAppCheckLogger for incomplete options during instantiation.

cc: @weixifan @rlazo

@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@ncooke3

ncooke3 commented May 4, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the reCAPTCHA Enterprise provider to Firebase App Check, including the provider implementation, a factory for instantiation, and unit tests. The Package.swift file is updated to include the RecaptchaEnterpriseProvider dependency and a helper function for flexible dependency management. Feedback was provided to add error logging when the provider is initialized with an empty site key to assist with debugging.

Comment thread FirebaseAppCheck/Sources/RecaptchaProvider/FIRRecaptchaProvider.m
@ncooke3

ncooke3 commented May 7, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the reCAPTCHA Enterprise provider for Firebase App Check, including its implementation, unit tests, and an E2E test application. Key changes involve adding the FIRRecaptchaEnterpriseProvider and its factory, updating the project configuration to support a new test target, and providing documentation for E2E testing. Feedback was provided regarding the requestRecaptchaToken method in the test app's AppDelegate, where the completion handler logic could lead to multiple calls or timeouts if not properly handled.

Comment thread FirebaseAppCheck/Apps/FIRAppCheckTestApp/FIRAppCheckTestApp/AppDelegate.swift Outdated
@ncooke3

ncooke3 commented May 7, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the reCAPTCHA Enterprise provider to the Firebase App Check SDK, including its implementation, factory, and unit tests. The test app has been significantly updated with new E2E tests, documentation, and logic to configure providers via environment variables. Additionally, Package.swift now supports local or branch-based dependency overrides for the App Check core library. Review feedback suggests enhancing test reliability by adding explicit non-nil assertions before comparisons and removing an unnecessary empty line in the provider implementation.

Comment thread FirebaseAppCheck/Sources/RecaptchaProvider/FIRRecaptchaProvider.m
@ncooke3

ncooke3 commented May 7, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the reCAPTCHA Enterprise provider to the Firebase App Check SDK, including the core implementation, unit tests, and a new E2E test suite within the sample app. The changes also improve dependency management in Package.swift and provide documentation for running E2E tests. Feedback highlights a potential redundancy in the test app's AppDelegate where a custom factory class duplicates functionality already present in the SDK.

Comment thread FirebaseAppCheck/Apps/FIRAppCheckTestApp/FIRAppCheckTestApp/AppDelegate.swift Outdated
@ncooke3

ncooke3 commented May 7, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the reCAPTCHA Enterprise provider to Firebase App Check, including its implementation, factory, and unit tests. It also updates the E2E test application with a new test target, automated tests for token acquisition and caching, and comprehensive documentation. Feedback was provided regarding a hardcoded SDK path in the project file that could cause build failures across different environments.

@ncooke3

ncooke3 commented May 7, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the reCAPTCHA Enterprise provider to Firebase App Check, including the provider implementation, a factory for instantiation, and comprehensive unit tests. Additionally, it adds a new End-to-End (E2E) test target to the sample app along with documentation on how to configure and run these tests. Feedback was provided regarding the test app's AppDelegate, suggesting a default value for the APP_CHECK_PROVIDER environment variable to prevent the application from crashing when run without specific configurations.

Comment thread FirebaseAppCheck/Apps/FIRAppCheckTestApp/FIRAppCheckTestApp/AppDelegate.swift Outdated
@ncooke3

ncooke3 commented May 7, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the reCAPTCHA Enterprise provider to the Firebase App Check SDK, including its implementation, a public factory for instantiation, and comprehensive unit tests. The sample test app is also updated with a new E2E test target, documentation, and logic to switch between providers via environment variables. Review feedback highlights several improvement opportunities: removing hardcoded SDK paths in the project file to ensure build portability, providing default values for environment variables in the test app to improve the developer experience, and using the SDK's public factory implementation instead of a local one within the test app.

Comment thread FirebaseAppCheck/Apps/FIRAppCheckTestApp/FIRAppCheckTestApp/AppDelegate.swift Outdated
Comment thread FirebaseAppCheck/Apps/FIRAppCheckTestApp/FIRAppCheckTestApp/AppDelegate.swift Outdated
Comment thread FirebaseAppCheck/Apps/FIRAppCheckTestApp/FIRAppCheckTestApp/AppDelegate.swift Outdated
@ncooke3

ncooke3 commented May 7, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the reCAPTCHA Enterprise provider to Firebase App Check. Key changes include the implementation of the FIRRecaptchaEnterpriseProvider and its corresponding factory, the addition of unit tests for these new components, and updates to the FIRAppCheckTestApp to support end-to-end testing. The project configuration files (Package.swift and .podspec) were also updated to include the necessary dependencies. Feedback was provided regarding a potential issue in the test app's storage reading logic where the completion handler might not be invoked in all execution paths, which could cause tests to hang.

Comment thread FirebaseAppCheck/Apps/FIRAppCheckTestApp/FIRAppCheckTestApp/AppDelegate.swift Outdated
Comment thread .github/workflows/sdk.appcheck.yml
Comment thread .github/workflows/sdk.appcheck.yml Outdated
ncooke3 and others added 12 commits June 9, 2026 19:55
Introduce an exemption in `check_imports.swift` to allow repo-relative
quote imports in the `#else` block (CocoaPods) of `SWIFT_PACKAGE` guards
for files under `SharedTestUtilities/`.

Why now:
This PR introduced `SWIFT_PACKAGE` conditional blocks to these shared
test utility files to support the new Swift Package Manager infrastructure
for `FirebaseAppCheck` unit tests. This enabled importing interop headers
via modular angle-bracket syntax in SPM.

Why the error happened:
The `check_imports.swift` script strictly enforces that all imports
within the `#else` block of `SWIFT_PACKAGE` must use angle brackets (`<`).
However, because `SharedTestUtilities` files are injected directly into
various host test targets in CocoaPods rather than being compiled as a
standalone pod with formal dependencies, they must rely on repo-relative
quote imports to resolve headers (e.g. `FIRAuthInterop.h`) via the
repository root search path. Using angle brackets causes CocoaPods compilation
failures, making the exemption necessary.
@ncooke3

ncooke3 commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

I'm working on final testing. The infra.samples.client_app should be fixed by setting an env var in them via #16253

Comment thread .github/workflows/infra.samples.client_app.yml
@ncooke3 ncooke3 marked this pull request as ready for review June 10, 2026 14:08
@ncooke3 ncooke3 requested a review from a team as a code owner June 10, 2026 14:08
@paulb777

Copy link
Copy Markdown
Member

What's the explanation for the CI failures?

@ncooke3

ncooke3 commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

What's the explanation for the CI failures?

Requires AppCheckCore to be released. I should be able to get everything to green with #16253

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants