Commit Graph
24 Commits
Author SHA1 Message Date
Ejiro Asiuwhu 625e3c06b6 test: add end-to-end integration test suite for live Stack Auth validation
Covers user CRUD lifecycle, team management, sessions, API key management,
authenticate_request with real request shapes, and async variants.
Requires STACK_E2E=1 env var and running Stack Auth instance.
2026-03-25 08:10:51 +01:00
Ejiro Asiuwhu b7e21a02e8 fix: replace broad exception catches with specific types and add debug logging
- _decode_jwt_payload catches only ValueError and json.JSONDecodeError
- Token refresh catches httpx.HTTPError, ValueError, KeyError with debug log
- authenticate_request catches jwt.PyJWTError, httpx.HTTPError, ValueError, KeyError
- Added docstring to _token_store_registry explaining purpose and test reset
- Updated test mocks to use jwt.PyJWTError instead of bare Exception
2026-03-25 08:08:12 +01:00
Ejiro Asiuwhu 7ec2e27a8e fix: add debug logging to authenticate_request exception handlers
- Add logger = logging.getLogger("stack_auth") at module level
- Emit logger.debug("authenticate_request failed", exc_info=True) in both sync and async handlers
- Add tests verifying debug log emission on verification failure
2026-03-25 08:02:10 +01:00
Ejiro Asiuwhu bfff27d4e7 fix: make RequestLike runtime_checkable and remove type: ignore from resolve_token_store
- Add @runtime_checkable decorator to RequestLike Protocol
- Replace bare fallback with isinstance(init, RequestLike) check in resolve_token_store
- Raise TypeError for invalid token store initializer types
- Add tests for isinstance checks and invalid input handling
2026-03-25 08:00:59 +01:00
Ejiro Asiuwhu 80f2c32f2e test: add failing tests for get_partial_user method
- Test get_partial_user returns TokenPartialUser from valid JWT
- Test returns None when no token store, explicit None, or empty store
- Test token_store override parameter
- Test async variant works identically (sync method, no I/O)
2026-03-25 07:52:42 +01:00
Ejiro Asiuwhu 6138ff0997 test: add failing tests for publishable_client_key and token store defaults
- Test publishable_client_key header included/omitted in _build_headers
- Test ExplicitTokenStore defaults to None without arguments
- Test resolve_token_store dict branch defaults missing keys to None
- Test StackServerApp/AsyncStackServerApp accept publishable_client_key
2026-03-25 07:50:42 +01:00
Ejiro Asiuwhu 1343d3ab2f test: add integration tests for payment, email, and data vault methods
- Add sync+async tests for list_products, get_item, grant_product, cancel_subscription
- Add tests for ServerItem.increase_quantity, decrease_quantity, try_decrease_quantity
- Add sync+async tests for send_email (html, text, multi-recipient) and get_email_delivery_stats
- Add sync+async tests for DataVaultStore get, set, delete, list_keys with NotFoundError handling
- Coverage grows from 299 to 337 tests, all passing
2026-03-25 02:26:45 +01:00
Ejiro Asiuwhu e8ce41bfbb fix: update team member profile test to include required user_id field
The user_id field was added to TeamMemberProfile during team management
implementation but the pre-existing model test was not updated.
2026-03-25 01:39:56 +01:00
Ejiro Asiuwhu eae4842ab1 feat: add oauth provider methods and connected accounts to both facades
- create_oauth_provider links OAuth provider to a user
- list_oauth_providers and get_oauth_provider for provider lookup
- list_connected_accounts as alias for list_oauth_providers
- Sync and async versions on both facade classes with tests
2026-03-25 01:37:25 +01:00
Ejiro Asiuwhu 7e41fc8f95 feat: add api key management methods to both facades
- User API key create/list/revoke on StackServerApp and AsyncStackServerApp
- Team API key create/list/revoke on both facades
- check_api_key validates any key and returns user_id/team_id
- Tests for all sync and async API key methods
2026-03-25 01:35:44 +01:00
Ejiro Asiuwhu c2f3a3a03a test: add failing tests for contact channel verification methods
- Tests for list, create, send verification, verify on sync facade
- Tests for all contact channel methods on async facade
- Covers optional fields and callback URL parameter
2026-03-25 01:30:07 +01:00
Ejiro Asiuwhu 6b012c02d7 test: add failing tests for permission management methods
- Tests for grant, revoke, list, has, get permission on sync facade
- Tests for all permission methods on async facade
- Covers team-scoped and project-level permissions
2026-03-25 01:28:28 +01:00
Ejiro Asiuwhu c48b9ca7fc test: add failing tests for team membership, invitations, and profiles
- Tests for add_team_member, remove_team_member
- Tests for send/list/revoke team invitations
- Tests for list_team_member_profiles and get_team_member_profile
- Async equivalents for all membership/invitation/profile operations
2026-03-25 01:24:01 +01:00
Ejiro Asiuwhu 3094338b42 test: add failing tests for team CRUD methods
- Tests for get_team, list_teams, create_team, update_team, delete_team
- Tests for get_team_by_api_key two-step lookup
- Async equivalents for all team CRUD operations
- Uses respx mocking pattern consistent with existing user tests
2026-03-25 01:22:09 +01:00
Ejiro Asiuwhu e1ccb718f4 test: add failing tests for session management methods
- list_sessions, get_session, revoke_session tests for sync and async
- Tests verify user_id query param, empty results, session filtering
2026-03-25 01:10:41 +01:00
Ejiro Asiuwhu fd3a816700 feat: add StackServerApp and AsyncStackServerApp with user CRUD
- StackServerApp (sync) and AsyncStackServerApp (async) facade classes
- get_user returns ServerUser or None on 404
- list_users with cursor/limit/order_by/desc/query/include_restricted/include_anonymous
- create_user sends only non-None fields
- update_user uses _UNSET sentinel to distinguish not-provided from explicit None
- delete_user returns None
- get_user_by_api_key performs two-step lookup via /api-keys/check then /users/{id}
- Both classes support context managers and compose API client + optional token store
2026-03-25 01:07:02 +01:00
Ejiro Asiuwhu 13f88755e3 test: add failing tests for StackServerApp and AsyncStackServerApp
- Tests for get_user, list_users, create_user, update_user, delete_user
- Tests for get_user_by_api_key two-step lookup
- Tests for sentinel pattern in update_user (None vs not-provided)
- Both sync and async facades covered with respx mocks
2026-03-25 01:05:49 +01:00
Ejiro Asiuwhu ad63cf03a0 test: add failing tests for token store subsystem
- TokenStore ABC, MemoryTokenStore, ExplicitTokenStore, RequestTokenStore
- Registry with shared instances per project_id
- CAS refresh algorithm with timing thresholds (20s/75s)
- Sync and async variants of get_or_fetch_likely_valid_tokens
- Helper functions: _is_fresh_enough, _is_expired, _decode_jwt_payload
2026-03-25 00:50:23 +01:00
Ejiro Asiuwhu ea427ed423 test: add failing tests for auth module
- Tests for decode_access_token_claims (valid JWT, defaults, malformed, missing sub, base64url)
- Tests for _extract_token_from_headers (Authorization, lowercase, x-stack-auth, missing)
- Tests for sync_authenticate_request and async_authenticate_request
2026-03-25 00:50:06 +01:00
Ejiro Asiuwhu 07c32d4a6e feat: add pagination support with cursor-based PaginatedResult
- PaginatedResult[T] generic wrapping nested {items, pagination: {next_cursor}} shape
- Convenience properties .next_cursor and .has_next_page
- Package __init__.py exports all models, errors, and PaginatedResult
- SyncAPIClient/AsyncAPIClient intentionally excluded from public API
- Tests verify pagination with ServerUser and Team types
2026-03-24 22:25:13 +01:00
Ejiro Asiuwhu 488e72a9cf feat: add user, team, session, contact channel, and permission pydantic models
- BaseUser and ServerUser with camelCase aliases and millis-to-datetime properties
- Team, ServerTeam, TeamMemberProfile, TeamInvitation with timestamp conversions
- ActiveSession with GeoInfo nested model
- ContactChannel and TeamPermission/ProjectPermission
- Tests for user and team model parsing, inheritance, and field conversion
2026-03-24 22:23:11 +01:00
Ejiro Asiuwhu 6b4cd35875 test: add failing tests for jwt verification and jwks fetching
- AsyncJWKSFetcher and SyncJWKSFetcher construction and key retrieval
- TTL cache behavior with 5-minute expiry
- Force-refresh on unknown kid
- verify_token for valid, expired, invalid signature, missing kid tokens
- CVE-2022-29217 protection: HS256 tokens rejected
2026-03-24 22:22:34 +01:00
Ejiro Asiuwhu fbe1c5bfc3 test: add failing tests for sync and async HTTP client
- 22 tests covering construction, headers, URL building, request pipeline
- Response processing with x-stack-actual-status and x-stack-known-error
- Retry logic with exponential backoff for idempotent methods
- 429 rate limit handling with Retry-After header
- Context manager protocol for both sync and async clients
2026-03-24 22:22:32 +01:00
Ejiro Asiuwhu 728533c87f test: add failing tests for python sdk error hierarchy and base model
- Test StackAuthError base class storage and string representation
- Test all 13 category subclasses inherit from StackAuthError
- Test from_response() dispatch for known and unknown error codes
- Test StackAuthModel config and millis conversion
- Package skeleton with pyproject.toml (stubs only, tests expected to fail)
2026-03-24 22:17:03 +01:00