Skip to content

OAuth device flow tests failing - mock sequences need debugging #11

@Hozyne-OpenBak

Description

@Hozyne-OpenBak

Problem

OAuth device flow implementation (Issue #3) is complete, but tests are failing due to mock configuration issues.

Current Status

Implementation: ✅ Complete

  • Device authorization logic
  • Token polling with exponential backoff
  • Error handling for all edge cases

Tests: ❌ 3/6 failing

Failing Tests

  1. pollForAccessToken returns access token when authorization is granted

    • Symptom: Test times out
    • Cause: axios.post mock stuck in pending state, never progresses to success
  2. Error handling for non-retryable errors

    • Symptom: Promise resolves instead of rejecting
    • Cause: invalid_grant error handling logic not terminating correctly
  3. pollForAccessToken handles slow_down

    • Symptom: Delay logic not triggering
    • Cause: Mock not simulating slow_down response correctly

Root Cause

axios.post mock sequences not configured to simulate sequential polling flow:

  • Expected: pendingpendingsuccess
  • Actual: Stuck in pending, never resolves

Additional Issues

  • Jest reports open handles (unclosed timers/async code)
  • Test framework may need configuration to detect/close handles properly

Next Steps

  1. Debug axios.post mock implementation in test file
  2. Ensure sequential responses work correctly for all test cases
  3. Verify all promises resolve/reject as expected
  4. Fix Jest open handles
  5. Run npm test to verify 6/6 passing

Files

  • Implementation: backend/src/oauth/oauth-client.js
  • Tests: backend/src/oauth/oauth-client.test.js

Priority

Medium - Implementation is functional, tests validate correctness but aren't blocking OAuth flow usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdashboardDashboard/platform related

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions