* Add google/foss product flavors (#461) Introduce a `distribution` flavor dimension on `:app` with two flavors: - `google` — the unchanged shipping build (Firebase/FCM/Crashlytics). - `foss` — compiles with zero firebase-*/google-services/Play-Services dependencies; google-services.json is not required to assemble it. The google-services and firebase-crashlytics Gradle plugins are now applied conditionally (skipped for a foss-only build, detected by requested task name), and the Firebase deps are scoped to `googleImplementation`. The three runtime seams get flavor-specific Koin bindings via a new `distributionModule`: CrashReporter, AnonymousAuthClient/FcmTokenProvider/DeviceAuthTokenProvider, and RenewalAuthProvider. The foss flavor binds NoOp/stub placeholders — real impls land in #462-#464; #461 only needs both flavors to assemble. Two direct FirebaseAuth call sites in shared `:app`/debug code (IntegrationSetupViewModel, AddIntegrationDestination, TestCommandProvider) are moved behind the seams so `main`/`debug`/`foss` compile Firebase-free. The shared `:work` module keeps its Firebase types for now; only the FCM `FcmReceiver` manifest entry moves to the google-flavor manifest so it is absent from the foss build's merged manifest. CI/task renames: assembleDebug -> assembleGoogle/FossDebug, testDebugUnitTest -> testGoogleDebugUnitTest, release builds the google flavor only (dual-flavor release is #465). Kover excludes the foss debug + flavored release test tasks. Part of #460. Fixes #461. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Load flavor distributionModule in integration test harness PR #461 moved CrashReporter, AnonymousAuthClient, FcmTokenProvider, DeviceAuthTokenProvider, and RenewalAuthProvider out of the base appModule into per-flavor distributionModule. RouseApplication registers both, but the integration-test Koin bootstrap (AppIntegrationTestHarness.bootKoin) only loaded appModule, so those five definitions were missing and every com.rousecontext.app.integration.* test failed with NoDefinitionFoundException. Add distributionModule (google variant on the integrationTest classpath) to the startKoin module list, between appModule and the test overrides so any harness fake still wins. Mirrors RouseApplication's base + distribution composition. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Fix stale variant-task references missed in the flavor rename (#461) - docs/self-hosting.md: :app:compileDebugKotlin -> :app:compileGoogleDebugKotlin - app/build.gradle.kts comment: testDebugUnitTest -> testGoogleDebugUnitTest Flagged by reviewer on PR #466. --------- Co-authored-by: Jason Monk <monkopedia@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
36 KiB
Rouse Context Test Coverage Audit
Date: 2026-04-06
Scope: Android app + Rust relay test suite
Goal: Identify why production bugs slip through despite hundreds of tests
Executive Summary
The Rouse Context project has ~70 test files covering unit, integration, and end-to-end scenarios across Android and Rust components. However, the test suite has critical gaps in three areas:
- Integration test fidelity — Tests use heavy mocks or manual frame pumping, missing real code paths
- End-to-end UI and configuration validation — No tests for design system compliance, hardcoded URLs, notification icons, or status bar colors
- Negative and edge-case scenarios — Missing tests for multi-record TLS frames, expired tokens, partial data, rapid reconnects, and FCM throttle behavior
Result: 12+ production bugs have leaked through despite extensive testing (connection status not updating, spurious WebSocket disconnects, TLS handshake failures on closed streams, FCM token send failures, invalid state transitions, etc.)
Test Inventory by Module
1. Core Tunnel (JVM tests: core/tunnel/src/jvmTest/)
Files: 10 test classes, ~3100 lines
| Test Class | Coverage | Status |
|---|---|---|
TunnelClientImplTest |
State transitions, FCM token, session handling | ✓ Good |
TlsAcceptTest |
TLS handshake over MuxStream | ✓ Good |
WebSocketMuxTest |
WebSocket -> mux frame conversion | ✓ Good |
MuxFrameTest (common) |
Frame encoding/decoding | ✓ Good |
MuxDemuxTest (common) |
Demux logic | ✓ Good |
TunnelConnectionStateMachineTest |
State machine transitions | ✓ Good |
OnboardingFlowTest |
Full onboarding workflow | ✓ Partial |
EndToEndSessionTest |
Real relay binary + TLS | ✓ Excellent |
OAuthEndToEndTest |
OAuth flow through tunnel | ✓ Good |
RealRelayIntegrationTest |
Raw WebSocket integration | ✓ Good |
Gaps:
- No test for multi-record TLS data frames (root cause of TLS handshake bugs)
- No test for rapid disconnect/reconnect cycles (actual bug: spurious disconnects seen)
- No test for idempotent disconnection (actual bug:
IllegalStateException: Invalid transition from DISCONNECTED to DISCONNECTED) - No test for FCM token send after reconnect (actual bug: JobCancellationException after reconnect)
- No test for state machine idempotency or concurrent state changes
- TunnelClientImplTest uses manual
MuxCodecframe pumping, not real TLS handshake variants
2. Core MCP (JVM tests: core/mcp/src/jvmTest/)
Files: 10 test classes
| Test Class | Coverage | Status |
|---|---|---|
McpProtocolTest |
tools/call, resources/list, concurrent requests, audit logging | ✓ Excellent |
HttpRoutingTest |
OAuth metadata, path routing | ✓ Good |
McpSessionTest |
HTTP POST, token auth, tool execution | ✓ Good |
AuthorizationCodeFlowTest |
Authorization code PKCE flow | ✓ Good |
AuthPageGalleryTest |
Generates static HTML variants | ⚠ Limited |
DeviceCodeFlowTest |
Device code flow | ✓ Good |
TokenStoreTest |
Token storage and expiry | ✓ Good |
AuthMiddlewareTest |
Bearer token validation | ✓ Good |
RateLimiterTest |
Rate limit enforcement | ✓ Good |
ErrorResponseTest |
Error handling | ✓ Good |
Gaps:
- No test for explicit nulls in JSON responses — HttpTransport serializes with
explicitNulls = falsebut no test verifies Claude can parse responses correctly - No test for CSP headers on auth page — AuthPageGalleryTest generates static HTML but doesn't verify CSP prevents inline styles from being blocked
- No browser-like test for auth page — Screenshots don't verify the page renders with styles in actual browser
- No test for malformed MCP requests — All tests use valid JSON-RPC
- No test for token expiry edge cases — Token revocation, concurrent refresh, race conditions
- No test for subdomain validation — URLs hardcoded to test domains, not production subdomains
- No test for missing OAuth endpoints — What happens if metadata endpoint is unreachable?
3. Core Bridge (JVM tests: core/bridge/src/jvmTest/)
Files: 2 test classes
| Test Class | Coverage | Status |
|---|---|---|
SessionHandlerTest |
Session routing and cleanup | ✓ Good |
TunnelSessionManagerTest |
Tunnel state management | ✓ Good |
Gaps:
- No tests for concurrent session operations
- No tests for cleanup on unexpected disconnects
- No tests for edge cases in session lifecycle
4. App (Unit tests: app/src/test/)
Files: 5 test classes
| Test Class | Coverage | Status |
|---|---|---|
MainDashboardViewModelTest |
State flow, integration visibility, audit entries | ✓ Good |
SettingsViewModelTest |
Settings state | ✓ Good |
AuditHistoryViewModelTest |
Audit list and filtering | ✓ Good |
AuthorizationApprovalViewModelTest |
Auth approval UI state | ✓ Good |
AuthApprovalReceiverTest |
BroadcastReceiver for approval | ✓ Good |
ScreenScreenshotTest |
Screenshot generation for all screens | ⚠ Limited |
Gaps (HIGH PRIORITY):
- No test for connection status indicator — Screenshots show "Disconnected" even when connected (actual bug: not tested at all)
- No test for design system application — No tests verify colors, typography, spacing follow Material Design 3
- No test for status bar icon color — Actual bug: icon colors incorrect (never tested)
- No test for notification icon color — Actual bug: icon doesn't render correctly (not tested)
- No test for double app bar on detail screens — Screenshots show structure but no assertion tests for it
- No test for navigation state — What happens on back press? Navigation cycles?
- No test for screen composition in dark mode — ScreenScreenshotTest captures but doesn't assert
- No test for hardcoded URLs in settings or onboarding — Integration URLs could be wrong (not tested)
5. Notifications (Unit tests: notifications/src/test/)
Files: 6 test classes
| Test Class | Coverage | Status |
|---|---|---|
NotificationChannelsTest |
Channel creation and importance | ✓ Good |
NotificationAdapterTest |
Action -> notification posting | ✓ Good |
AuthRequestNotifierTest |
Auth request notification | ✓ Good |
AuditDaoTest |
Audit database persistence | ✓ Good |
NotificationDaoTest |
Capture database persistence | ✓ Good |
NotificationScreenshotTest |
Screenshot previews | ⚠ Limited |
Gaps (HIGH PRIORITY):
- No test for small icon resource ID — Actual bug: icon not rendering correctly (never verified)
- No test for color field — Notification color field may not match theme
- No test for icon rendering on actual device — Screenshot tests don't verify on real Android
- No test for notification compatibility on different Android versions
- No test for accessibility attributes (content descriptions, etc.)
6. Work (Unit tests: work/src/test/)
Files: 5 test classes
| Test Class | Coverage | Status |
|---|---|---|
FcmDispatchTest |
FCM message routing | ✓ Good |
CertRenewalWorkerTest |
Cert renewal task | ✓ Good |
SecurityCheckWorkerTest |
Security checks | ✓ Good |
IdleTimeoutTest |
Idle timeout behavior | ⚠ Partial |
WakelockManagerTest |
Wakelock acquisition/release | ⚠ Partial |
Gaps (HIGH PRIORITY):
- No test for FCM wake throttle — Actual bug: wake throttle too aggressive (never tested with real timing)
- No test for concurrent FCM messages — What if multiple wakes arrive in rapid succession?
- No test for FCM token failure handling — Actual bug:
Failed to send FCM token to relayafter reconnect (not tested) - No test for actual work scheduling — Tests don't verify WorkManager enqueue behavior
7. Relay (Rust tests: relay/tests/)
Files: 13 test files
| Test File | Coverage | Status |
|---|---|---|
integration_test.rs |
Full WebSocket connection, mux frames | ✓ Good |
passthrough_test.rs |
Stream passthrough logic | ✓ Good |
mux_lifecycle_test.rs |
Stream open/close lifecycle | ✓ Good |
mux_frame_test.rs |
Frame encoding/decoding | ✓ Good |
config_test.rs |
Config file parsing and env overrides | ✓ Good |
api_register_test.rs |
Client registration endpoint | ✓ Good |
api_wake_test.rs |
Wake endpoint behavior | ⚠ Limited |
api_status_test.rs |
Status endpoint | ✓ Good |
api_renew_test.rs |
Cert renewal endpoint | ⚠ Limited |
sni_test.rs |
SNI extraction from client certs | ✓ Good |
subdomain_test.rs |
Subdomain validation | ✓ Good |
maintenance_test.rs |
Device maintenance loop | ⚠ Limited |
shutdown_test.rs |
Clean shutdown | ✓ Good |
Gaps:
- No test for multi-record TLS frames — Actual bug: TLS handshake fails on multi-record data (never tested)
- No test for WebSocket frame boundaries — What if TLS record spans multiple WebSocket frames?
- No test for corrupted or incomplete frames — Negative test coverage is weak
- No test for stream cleanup on error — Error frames don't properly close streams (not verified)
- No test for concurrent stream limits — max_streams_per_device not enforced in tests
- No test for FCM wake race conditions — What if device disconnects while wake is in flight?
8. Health Connect (Unit tests: health/src/test/)
Files: 2 test classes
| Test Class | Coverage | Status |
|---|---|---|
HealthConnectMcpServerTest |
Tool registration and basic calls | ✓ Good |
RecordTypeRegistryTest |
Health record type mapping | ✓ Good |
Gaps:
- No tests for permission denial scenarios
- No tests for missing data handling
9. Outreach, Usage (Unit tests)
Files: 2 test classes, basic coverage
Gaps:
- Minimal test coverage
- No integration tests
10. API, Device Tests
Files: 6 test classes
| Test Class | Coverage | Status |
|---|---|---|
IntegrationStateStoreTest |
State persistence | ✓ Good |
IntegrationStateTest |
State model | ✓ Good |
DeviceIntegrationTest |
End-to-end device flow | ✓ Good |
TunnelRelayIntegrationTest |
Tunnel + relay integration | ⚠ Limited |
Gap Analysis: Production Bugs vs. Test Coverage
Bug 1: TLS Handshake Fails on Multi-Record Data Frames
Symptom: "TLS handshake failure" after successful WebSocket connection
Root Cause: TLS record may span multiple WebSocket frames; decoder doesn't handle this
Should be tested by:
- ✗ No test in
TlsAcceptTestfor multi-record frames - ✗ No test in relay
mux_frame_test.rsfor frame boundary conditions - ✗ EndToEndSessionTest uses real handshake but doesn't deliberately send split frames
Test Location: core/tunnel/src/jvmTest/kotlin/com/rousecontext/tunnel/TlsAcceptTest.kt (add test)
Test Location: relay/tests/mux_frame_test.rs (add test)
Bug 2: OAuth Auth Page Renders with Broken Styles
Symptom: Styles not applied on auth page (CSP blocking inline