This guide explains how to integrate POD authentication testing into continuous integration and deployment pipelines. For general adaptation, see Adapting for Your App.
Documentation index: See README.md for complete documentation navigation.
Running integration tests with POD authentication in CI/CD requires:
name: Integration Tests
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
jobs:
integration-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.24.0'
- name: Install Chrome
run: |
wget -q -O - \
https://dl-ssl.google.com/linux/linux_signing_key.pub \
| sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] \
http://dl.google.com/linux/chrome/deb/ stable main" \
>> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install -y google-chrome-stable
- name: Install dependencies
run: flutter pub get
- name: Setup test credentials
run: |
mkdir -p integration_test/fixtures
echo '$' \
> integration_test/fixtures/test_credentials.json
- name: Generate auth data
run: |
dart run integration_test/tools/generate_auth_data.dart
- name: Run integration tests
run: |
flutter test integration_test/app_test.dart \
-d linux --dart-define=INTERACT=0
flutter test integration_test/workflows/your_test.dart \
-d linux --dart-define=INTERACT=0
Chrome installation:
Test credentials setup:
test_credentials.json in fixtures directoryAuth data generation:
complete_auth_data.json for testsIndividual test execution:
INTERACT=0 for quick executionNavigate to repository settings:
Repository → Settings → Secrets and variables → Actions
Add secret named TEST_CREDENTIALS with JSON content:
{
"email": "test@example.com",
"password": "your-test-password",
"securityKey": "1234",
"webId": "https://pods.example.com/test/profile/card#me",
"podUrl": "https://pods.example.com/test/",
"issuer": "https://pods.example.com/"
}
- name: Setup test credentials
run: |
mkdir -p integration_test/fixtures
echo '$' \
> integration_test/fixtures/test_credentials.json
For different environments (staging, production):
- name: Setup credentials (staging)
if: github.ref == 'refs/heads/dev'
run: |
echo '$' \
> integration_test/fixtures/test_credentials.json
- name: Setup credentials (production)
if: github.ref == 'refs/heads/main'
run: |
echo '$' \
> integration_test/fixtures/test_credentials.json
Generate tokens locally, encrypt, store in CI:
# Generate auth data locally
dart run integration_test/tools/generate_auth_data.dart
# Encrypt the file
gpg --symmetric --cipher-algo AES256 \
integration_test/fixtures/complete_auth_data.json
# Commit encrypted version
git add integration_test/fixtures/complete_auth_data.json.gpg
git commit -m "Add encrypted auth data for CI"
CI workflow:
- name: Decrypt auth data
run: |
echo "$" | \
gpg --quiet --batch --yes --decrypt \
--passphrase-fd 0 \
--output integration_test/fixtures/complete_auth_data.json \
integration_test/fixtures/complete_auth_data.json.gpg
Pros:
Cons:
Generate fresh tokens in CI using browser automation:
- name: Generate auth data
run: dart run integration_test/tools/generate_auth_data.dart
Pros:
Cons:
Create mock POD service for CI that bypasses real authentication:
// In test setup
if (const bool.fromEnvironment('CI')) {
// Use mock auth for CI
await MockAuthService.injectMockCredentials();
} else {
// Use real auth for local development
await CredentialInjector.injectFullAuth();
}
Pros:
Cons:
runs-on: ubuntu-latest
steps:
- name: Install Chrome
run: |
sudo apt-get update
sudo apt-get install -y google-chrome-stable
- name: Run tests
run: flutter test integration_test/ -d linux
runs-on: macos-latest
steps:
- name: Install Chrome
run: brew install --cask google-chrome
- name: Run tests
run: flutter test integration_test/ -d macos
runs-on: windows-latest
steps:
- name: Install Chrome
run: |
choco install googlechrome -y
- name: Run tests
run: flutter test integration_test/ -d windows
When setting up CI/CD for your adapted app:
Phase 1: Secrets Setup
TEST_CREDENTIALS to GitHub secretsPhase 2: Workflow Configuration
.github/workflows/integration-tests.ymlPhase 3: Test Execution
INTERACT=0 for quick execution-d linux/windows/macos)AUTO_REGENERATE=false for POD testsPhase 4: Verification
Symptom: Puppeteer can’t find Chrome executable
Solution: Verify Chrome installation in workflow:
- name: Verify Chrome installation
run: which google-chrome || which chromium-browser
Symptom: Browser automation times out in CI
Solution: Increase timeout or use pre-generated tokens:
// In generate_auth_data.dart
final browser = await puppeteer.launch(
timeout: Duration(minutes: 5), // Increased from default
);
Symptom: Integration tests fail only in CI environment
Possible causes:
Solution: Add debug logging:
- name: Run tests with verbose output
run: |
flutter test integration_test/ \
-d linux --dart-define=INTERACT=0 --verbose
Symptom: First test passes, subsequent tests fail
Solution: Run tests individually (see example workflow above)
- name: Run tests individually
run: |
flutter test integration_test/app_test.dart -d linux
flutter test integration_test/workflows/test1.dart -d linux
flutter test integration_test/workflows/test2.dart -d linux