Skip to content

Comments

add test for oauth providers#2681

Merged
hayescode merged 5 commits intoChainlit:mainfrom
codomposer:feat/test_oauth_providers
Nov 21, 2025
Merged

add test for oauth providers#2681
hayescode merged 5 commits intoChainlit:mainfrom
codomposer:feat/test_oauth_providers

Conversation

@codomposer
Copy link
Contributor

@codomposer codomposer commented Nov 21, 2025

Add Comprehensive Tests for OAuth Providers

Description

This PR adds comprehensive unit tests for all OAuth providers in the Chainlit authentication system. Previously, the oauth_providers.py module had no dedicated test coverage despite being critical for user authentication.

Test Coverage

Base Provider Tests

  • Environment variable configuration detection
  • Prompt parameter handling (provider-specific, global, and default)
  • Abstract method implementation verification

Provider-Specific Tests

  • Initialization and configuration
  • Token retrieval and validation
  • User info parsing
  • Error handling (missing tokens, HTTP errors)
  • Custom URL configuration
  • Provider-specific features (refresh tokens, photo retrieval, etc.)

Edge Cases

  • HTTP error handling
  • Domain trailing slash normalization
  • Prompt parameter injection
  • Custom authorization server paths (Okta)
  • Multi-tenant vs single-tenant configurations (Azure AD)
  • Custom user identifier fields (Generic provider)

Testing Approach

  • Uses pytest with async support (@pytest.mark.asyncio)
  • Mocks HTTP requests with httpx.AsyncClient
  • Uses patch.dict for environment variable isolation
  • Module reloading for class-level attribute testing
  • Follows existing test patterns from test_mcp.py and test_translations.py

Contribution by Gittensor, learn more at https://gittensor.io/

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. auth Pertaining to authentication. labels Nov 21, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@hayescode hayescode added this pull request to the merge queue Nov 21, 2025
Merged via the queue into Chainlit:main with commit 0843245 Nov 21, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth Pertaining to authentication. size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants