Skip to content

[Feature] Test environment login bypass for automation #47

@crazygo

Description

@crazygo

Description

The project currently uses GitHub OAuth for authentication. However, this login method is inconvenient for automated testing because:

  1. In virtual/test environments, GitHub is not logged in
  2. Cannot automatically bypass OAuth authorization flow
  3. Test accounts need a way to access the main application without manual OAuth

We need a solution to allow test accounts to log in through an alternative mechanism in test environments.

Technical Approach

Environment Variable + Test Token Injection

Core idea: Inject a test JWT token via environment variable, bypassing OAuth in test environments.

  1. Extend AuthService: Read token from environment variable BRICKS_TEST_TOKEN first
  2. Add isTestMode(): Detect if running in test environment
  3. Adapt LoginScreen: Show quick login entry in test mode
  4. Run command: flutter test --dart-define=BRICKS_TEST_TOKEN=xxx

Security Considerations

  • Test tokens should have limited permissions/validity
  • isTestMode() check ensures test logic won't trigger in production
  • Test tokens should be rotated regularly, not hardcoded

Acceptance Criteria

  • AuthService supports reading test token from environment variable
  • isTestMode() method correctly detects test environment
  • LoginScreen can skip OAuth in test mode
  • Test token can be injected via --dart-define
  • Production environment is not affected (test logic disabled)
  • Integration tests verify the complete flow

Related

  • Thread: 1488041850974765056

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions