mirror of
https://github.com/hanzoai/opencode-openai-codex-auth.git
synced 2026-09-24 17:01:02 +00:00
This PR standardizes all documentation and configuration on GPT 5.1 model identifiers, removes deprecated GPT 5.0 models, and enforces full-opencode.json as the only officially supported configuration. The changes address GPT 5 model temperamental behavior and ensure users have the proper setup for reliable operation with OpenCode. Co-authored-by: Hanzo Dev <[email protected]>
Test Suite
This directory contains the comprehensive test suite for the OpenAI Codex OAuth plugin.
Test Structure
test/
├── README.md # This file
├── auth.test.ts # OAuth authentication tests
├── config.test.ts # Configuration parsing tests
├── logger.test.ts # Logging functionality tests
├── request-transformer.test.ts # Request transformation tests
└── response-handler.test.ts # Response handling tests
Running Tests
# Run all tests once
npm test
# Watch mode (re-run on file changes)
npm run test:watch
# Visual test UI
npm run test:ui
# Generate coverage report
npm run test:coverage
Test Coverage
auth.test.ts (16 tests)
Tests OAuth authentication functionality:
- State generation and uniqueness
- Authorization input parsing (URL, code#state, query string formats)
- JWT decoding and payload extraction
- Authorization flow creation with PKCE
- URL parameter validation
config.test.ts (13 tests)
Tests configuration parsing and merging:
- Global configuration application
- Per-model configuration overrides
- Mixed configuration (global + per-model)
- Default values and fallbacks
- Reasoning effort normalization (minimal → low for codex)
- Lightweight model detection (nano, mini)
request-transformer.test.ts (30 tests)
Tests request body transformations:
- Model name normalization (all variants → gpt-5 or gpt-5-codex)
- Input filtering (removing stored conversation history)
- Tool remap message injection
- Reasoning configuration application
- Text verbosity settings
- Encrypted reasoning content inclusion
- Unsupported parameter removal
response-handler.test.ts (10 tests)
Tests SSE to JSON conversion:
- Content-type header management
- SSE stream parsing (response.done, response.completed)
- Malformed JSON handling
- Empty stream handling
- Status preservation
logger.test.ts (5 tests)
Tests logging functionality:
- LOGGING_ENABLED constant
- logRequest function parameter handling
- Complex data structure support
Test Philosophy
- Comprehensive Coverage: Each module has extensive tests covering normal cases, edge cases, and error conditions
- Fast Execution: All tests run in < 250ms
- No External Dependencies: Tests use mocked data and don't make real API calls
- Type Safety: All tests are written in TypeScript with full type checking
CI/CD Integration
Tests automatically run in GitHub Actions on:
- Every push to main
- Every pull request
The CI workflow tests against multiple Node.js versions (18.x, 20.x, 22.x) to ensure compatibility.
Adding New Tests
When adding new functionality:
- Create or update the relevant test file
- Follow the existing pattern using vitest's
describeanditblocks - Ensure tests are isolated and don't depend on external state
- Run
npm testto verify all tests pass - Run
npm run typecheckto ensure TypeScript types are correct
Example Configurations
See the config/ directory for working configuration examples:
minimal-opencode.json: Simplest setup with defaultsfull-opencode.json: Complete example with all model variants