Chris Coutinho and Claude Opus 4.5
815a09be34
test(astrolabe): add unit tests for background token refresh
...
- Fix McpTokenStorageTest: add IDBConnection mock for new constructor parameter
- Add doctrine/dbal dev dependency for IQueryBuilder mock support
- Add tests for getAllUsersWithTokens() database query method
- Create RefreshUserTokensTest with comprehensive coverage:
- Job interval configuration (15 min)
- Token refresh threshold logic (50% lifetime)
- issued_at tracking for accurate lifetime calculation
- Fallback to default lifetime when issued_at missing
- Token rotation handling
- Error handling and logging
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2026-01-27 12:23:06 +01:00
Chris Coutinho and Claude Opus 4.5
e48c5fa9a2
fix(astrolabe): delete stale tokens when refresh fails
...
- Delete stored token when refresh callback fails or returns null
- Delete stored token when expired with no refresh callback available
- Fix test namespaces (Service → OCA\Astrolabe\Tests\Unit\Service)
- Update tests to verify token deletion on refresh failure
Prevents repeated refresh attempts with stale tokens that will never
succeed, improving error handling and reducing unnecessary API calls.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2026-01-17 14:21:53 +01:00
Chris Coutinho and Claude Opus 4.5
fef13a6d3d
test(astrolabe): add comprehensive unit tests for token refresh and storage
...
Add unit tests addressing reviewer feedback on test coverage gaps:
IdpTokenRefresher::refreshAccessToken() tests:
- Token refresh with internal Nextcloud OIDC
- Token refresh with external IdP (Keycloak)
- Error handling: missing client_secret, missing MCP URL
- Error handling: invalid responses, HTTP exceptions
- Token rotation validation (missing refresh_token in response)
McpTokenStorage tests (multi-user basic auth):
- OAuth token storage, retrieval, deletion
- Token expiration checks with 60-second buffer
- getAccessToken with automatic refresh callback
- App password storage for background sync
- hasBackgroundSyncAccess() for both OAuth and app passwords
- Background sync type detection and timestamp tracking
Test coverage: 41 tests, 76 assertions (up from 5 tests)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2026-01-17 11:00:45 +01:00