Skip to content
Draft
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
33905d4
feat(appcheck): implement RecaptchaEnterpriseProvider and tests (#16150)
ncooke3 May 4, 2026
250212e
package.swift newline
ncooke3 May 4, 2026
5f894cb
fix(AppCheck): log error when siteKey is empty in provider init
ncooke3 May 4, 2026
0cee53b
tests: add manual e2e tests
ncooke3 May 7, 2026
8eecc10
feedback
ncooke3 May 7, 2026
b0e2039
review
ncooke3 May 7, 2026
0cbf732
update versions
ncooke3 May 7, 2026
bb35028
fixes and review
ncooke3 May 7, 2026
3c84e4a
Merge branch 'main' into nc/recaptcha-1
ncooke3 May 7, 2026
10ff653
fixes
ncooke3 May 7, 2026
c5d6cd4
app dele
ncooke3 May 7, 2026
4d84847
e2e
ncooke3 May 7, 2026
180b29f
podfile
ncooke3 May 7, 2026
cee38df
review:
ncooke3 May 7, 2026
098066d
Review
ncooke3 May 7, 2026
db54acf
fix podfile
ncooke3 May 7, 2026
4a67322
add fixes to e2e file
ncooke3 May 7, 2026
678bf77
e2e updates
ncooke3 May 8, 2026
197949c
delegate fixes
ncooke3 May 8, 2026
2c564e7
rewrite in swift
ncooke3 May 13, 2026
0abebb5
doc comments:
ncooke3 May 13, 2026
a977ee3
Refactor and modernize Recaptcha Enterprise provider testing
ncooke3 May 13, 2026
984b525
rename
ncooke3 May 28, 2026
39b2adb
public getter and setter for site key
ncooke3 May 28, 2026
94a1f8d
recaptcha factory rename and options handling
ncooke3 May 28, 2026
ce8264f
Merge remote-tracking branch 'origin/main' into nc/recaptcha-1
ncooke3 May 28, 2026
10c3814
recaptchanenterprise -> recaptcha renames
ncooke3 May 28, 2026
2fb8aed
renames cont
ncooke3 May 28, 2026
74817fd
logging improvements
ncooke3 May 28, 2026
fae69fa
Apply suggestion from @paulb777
ncooke3 May 28, 2026
7fd95eb
Update FirebaseAppCheck/Apps/FIRAppCheckTestApp/E2E_TESTING.md
ncooke3 May 28, 2026
e092cf9
Update FirebaseAppCheck/Apps/FIRAppCheckTestApp/E2E_TESTING.md
ncooke3 May 28, 2026
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
44 changes: 44 additions & 0 deletions .github/workflows/_spm.yml
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

todo: Address feedback in PR separately.

Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ on:
required: false
default: false

# Custom environment variables to inject into the jobs.
# Expected to be a JSON-formatted string.
# Example: '{"FIREBASE_APP_CHECK_BRANCH": "nc/target-split"}'
env_vars:
type: string
required: false
default: "{}"

outputs:
cache_key:
description: "The cache key for the Swift package resolution."
Expand All @@ -72,6 +80,24 @@ jobs:
cache_key: ${{ steps.generate_cache_key.outputs.cache_key }}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Set Custom Environment Variables
run: |
python3 -c '
import os, json
try:
env_vars = json.loads(os.environ.get("CUSTOM_ENV_VARS", "{}"))
if not isinstance(env_vars, dict):
raise ValueError("env_vars must be a JSON object")
with open(os.environ["GITHUB_ENV"], "a") as f:
for k, v in env_vars.items():
f.write(f"{k}={v}\n")
except json.JSONDecodeError:
print("Warning: env_vars is not valid JSON. Skipping.")
except Exception as e:
print(f"Error setting env vars: {e}")
'
env:
CUSTOM_ENV_VARS: ${{ inputs.env_vars }}
- name: Xcode
run: sudo xcode-select -s /Applications/Xcode_26.4.app/Contents/Developer
- name: Generate Swift Package.resolved
Expand Down Expand Up @@ -110,6 +136,24 @@ jobs:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Set Custom Environment Variables
run: |
python3 -c '
import os, json
try:
env_vars = json.loads(os.environ.get("CUSTOM_ENV_VARS", "{}"))
if not isinstance(env_vars, dict):
raise ValueError("env_vars must be a JSON object")
with open(os.environ["GITHUB_ENV"], "a") as f:
for k, v in env_vars.items():
f.write(f"{k}={v}\n")
except json.JSONDecodeError:
print("Warning: env_vars is not valid JSON. Skipping.")
except Exception as e:
print(f"Error setting env vars: {e}")
'
env:
CUSTOM_ENV_VARS: ${{ inputs.env_vars }}
- uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
path: .build
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/sdk.appcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
uses: ./.github/workflows/_spm.yml
with:
target: ${{ matrix.target }}
env_vars: '{"FIREBASE_APP_CHECK_BRANCH": "nc/target-split"}'


catalyst:
uses: ./.github/workflows/_catalyst.yml
Expand Down
2 changes: 1 addition & 1 deletion FirebaseAppCheck.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Pod::Spec.new do |s|
s.osx.weak_framework = 'DeviceCheck'
s.tvos.weak_framework = 'DeviceCheck'

s.dependency 'AppCheckCore', '~> 11.0'
s.dependency 'AppCheckCore', '~> 11.3'
Comment thread
ncooke3 marked this conversation as resolved.
Comment thread
ncooke3 marked this conversation as resolved.
s.dependency 'FirebaseAppCheckInterop', '~> 12.14.0'
s.dependency 'FirebaseCore', '~> 12.14.0'
s.dependency 'GoogleUtilities/Environment', '~> 8.1'
Expand Down
64 changes: 64 additions & 0 deletions FirebaseAppCheck/Apps/FIRAppCheckTestApp/E2E_TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# E2E Testing with FIRAppCheckTestApp

This document provides information on how to configure and run End-to-End (E2E) tests for App Check providers using this sample app.

## Configurability

The app's behavior can be configured using environment variables passed during test execution.

### Environment Variables

Starting with Xcode 13, you can pass environment variables directly to the test runner by prefixing them with `TEST_RUNNER_`. The prefix is stripped when it reaches the test process.

- **`TEST_RUNNER_RECAPTCHA_SITE_KEY`**: The reCAPTCHA Enterprise site key used by the `RecaptchaEnterpriseProvider`.
- **Access in Code**: Read via `ProcessInfo.processInfo.environment["RECAPTCHA_SITE_KEY"]`.
- **`TEST_RUNNER_APP_CHECK_PROVIDER`**: Specifies which App Check provider factory to use.
- **Supported Values**: `recaptcha` (default), `debug`.
- **Access in Code**: Read via `ProcessInfo.processInfo.environment["APP_CHECK_PROVIDER"]`.

### Manual Override

For local debugging and manual testing, you can override the environment variables by setting `manualProviderOverride` in `AppDelegate.swift`:

```swift
let manualProviderOverride: String? = "debug" // Force debug provider
```

## Running Tests

The commands below should be run from the **repository root**.

### Prerequisites
- Ensure you have a local checkout of the `app-check` repository if you are developing it locally. Set `FIREBASE_APP_CHECK_LOCAL_PATH` to point to it.

### Sample Commands

#### Run tests with reCAPTCHA Enterprise provider
Comment thread
ncooke3 marked this conversation as resolved.
Outdated

```bash
export TEST_RUNNER_RECAPTCHA_SITE_KEY="your_site_key_here"
export TEST_RUNNER_APP_CHECK_PROVIDER="recaptcha"
export FIREBASE_APP_CHECK_LOCAL_PATH="/path/to/your/local/app-check"

xcodebuild test \
-workspace FirebaseAppCheck/Apps/FIRAppCheckTestApp/FIRAppCheckTestApp.xcworkspace \
-scheme FIRAppCheckTestApp \
-destination 'platform=iOS Simulator,name=iPhone 16'
```

#### Run tests with Debug provider

```bash
export TEST_RUNNER_APP_CHECK_PROVIDER="debug"
export FIREBASE_APP_CHECK_LOCAL_PATH="/path/to/your/local/app-check"

xcodebuild test \
-workspace FirebaseAppCheck/Apps/FIRAppCheckTestApp/FIRAppCheckTestApp.xcworkspace \
-scheme FIRAppCheckTestApp \
-destination 'platform=iOS Simulator,name=iPhone 16'
```
*Note: The Debug provider might require you to register the generated debug token in the Firebase Console for the tests to pass if they interact with live services.*

## Project Structure

- **`FIRAppCheckTestAppTests`**: A hosted unit test target containing the test cases. It runs inside the app process to have access to the full app context.
Loading
Loading