WIP: Add authorization service tests #71
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Status: Work in Progress - PR #2 of 14 in the test coverage improvement plan
Depends on: #70 (test infrastructure)
Add comprehensive unit tests for the AuthorizationService to cover all authorization scenarios.
Changes
Authorization Service Tests (10 new tests)
Happy Path:
test_fleet_administrator_with_valid_tenant- FleetAdmin can access with valid tenanttest_fleet_operator_with_valid_fleet- FleetOperator can access fleet in their listError Paths:
test_fleet_administrator_with_invalid_tenant- Rejects invalid tenanttest_fleet_operator_with_invalid_fleet- Rejects fleet not in operator's listtest_fleet_operator_without_fleet_list- Rejects operator without fleet_list claimtest_invalid_role- Rejects insufficient role (FleetObserver)test_missing_tenant_list- Rejects token without tenant_listtest_missing_roles- Rejects token without rolestest_sso_token_verification_error- Handles SSO verification failurestest_device_service_fleet_id_error- Handles device service errorsCoverage
Tests validate all authorization rules:
Test Results
✅ All 38 tests pass (27 existing + 10 new authorization + 1 doc test)
Note on Keycloak Provider
KeycloakProvider unit tests were skipped as:
verify_token()requires mocking HTTP client (complex)validate_portal_token.rs)create_frontend_config_file()requires AppConfig setupFuture PR could add these if needed.
Test Plan
Related
Signed-off-by: Jan Zachmann [email protected]