moviestar

Integration Test Setup

New to POD authentication? Read Understanding POD Authentication first to learn why OAuth, DPoP, and browser automation are necessary.

Documentation index: See README.md for complete documentation navigation.

This document describes the initial setup for E2E testing infrastructure for Movie Star using Flutter’s integration_test package.

For day-to-day testing usage, see Testing Guide.

Overview

Movie Star uses integration_test for cross-platform E2E testing on Windows, Linux, macOS, web, Android, and iOS.

Installation

Dependencies

Add the following to pubspec.yaml:

dev_dependencies:
  integration_test:
    sdk: flutter
  puppeteer: ^3.19.0  # Browser automation for POD OAuth testing
  pointycastle: ^3.9.1  # RSA key generation for DPoP

Run flutter pub get to install dependencies.

Platform-Specific Setup

Linux

flutter config --enable-linux-desktop
flutter create --platforms=linux .

Windows

flutter config --enable-windows-desktop
flutter create --platforms=windows .

macOS

flutter config --enable-macos-desktop
flutter create --platforms=macos .

Test Organization

integration_test/
├── fixtures/               # Test data and auth tokens (gitignored)
│   ├── test_credentials.json
│   └── complete_auth_data.json
├── helpers/                # Test utilities
│   ├── credential_injector.dart
│   ├── pod_auth_automator.dart
│   ├── oauth_helpers.dart
│   └── test_constants.dart
├── utils/                  # Development tools
│   ├── delays.dart
│   ├── generate_auth_data.dart
│   ├── generate_auth_data.dart
│   └── discover_oauth_params.dart
├── workflows/              # E2E workflow tests
│   ├── pod_favorites_real_test.dart
│   └── visual_login_test.dart
├── app_test.dart          # Basic integration test
└── app_hive_test.dart     # Hive initialization test

Initial Credential Setup

1. Create Test Credentials File

Create integration_test/fixtures/test_credentials.json:

{
  "email": "test@anu.edu.au",
  "password": "YOUR_TEST_PASSWORD",
  "securityKey": "1234",
  "webId": "https://pods.dev.solidcommunity.au/healthpod-test/profile/card#me",
  "podUrl": "https://pods.dev.solidcommunity.au/healthpod-test/",
  "issuer": "https://pods.dev.solidcommunity.au/"
}

2. Update Credentials

3. Verify .gitignore

Ensure these files are NOT committed:

# Integration test auth data (contains sensitive tokens)
integration_test/fixtures/complete_auth_data.json
integration_test/fixtures/test_credentials.json

Extract Authentication Data

First-Time Setup

Before running POD-authenticated tests, extract complete auth data:

# Automated extraction (recommended)
dart run integration_test/tools/generate_auth_data.dart

# Manual extraction (if automation fails)
flutter run integration_test/tools/generate_auth_data.dart -d linux

This generates:

Token Expiration: OAuth tokens expire after 1 hour. Re-run extraction if tests fail with invalid_grant errors.

Complete Auth Data vs Legacy Tokens

Why Complete Auth Data?

The solidpod package requires complete authentication data including:

Legacy token injection (basic access_token/id_token only) will fail with:

OpenIdException(invalid_grant): grant request is invalid

What Gets Generated

The extraction tools generate RSA keypairs and build the complete auth structure:

{
  "web_id": "https://pods.dev.solidcommunity.au/healthpod-test/profile/card#me",
  "logout_url": "https://pods.dev.solidcommunity.au/logout",
  "rsa_info": "{...RSA keypair in PEM format...}",
  "auth_response": {
    "access_token": "eyJhbGc...",
    "id_token": "eyJhbGc...",
    "token_type": "DPoP",
    ...
  }
}

Browser Automation Details

OAuth Flow Automation

The automated extraction performs:

Duration: ~15-20 seconds

Requirements

CI/CD Integration

For continuous integration environments:

Option A: Pre-Generated Tokens

Option B: On-Demand Extraction

Option C: Mock POD Service

Security Best Practices

IMPORTANT:

DO:

DON’T:

Troubleshooting Setup Issues

Chrome/Chromium Not Found

Problem: generate_auth_data.dart fails to find browser

Solution:

# Linux
sudo apt install chromium-browser

# macOS
brew install chromium

# Windows
# Download Chrome from https://www.google.com/chrome/

Token Extraction Timeout

Problem: Browser automation times out

Solution:

# Run with visible browser to debug
dart run integration_test/tools/generate_auth_data.dart --no-headless

Invalid Credentials

Problem: Login fails during extraction

Solution:

Platform Not Enabled

Problem: flutter test fails with “No device found”

Solution:

# Check enabled platforms
flutter config

# Enable desktop platform
flutter config --enable-linux-desktop  # or --enable-windows-desktop

# Verify devices available
flutter devices

Next Steps

After completing setup:

References