test: end-to-end RP+OAuth integration tests#1327
Draft
SalimKayal wants to merge 2 commits into
Draft
Conversation
This was referenced May 21, 2026
Open
1564a19 to
898df74
Compare
52fa3bd to
2ac8da5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
This chunk adds HTTP-level end-to-end tests that exercise the full integration between resource pools and OAuth2 providers through the Sanic test client. The tests verify that the auto-grant/revoke logic implemented in #1314 and #1317 works correctly from the API surface: users gain and lose resource pool visibility by connecting to and disconnecting from OAuth providers, and admins can swap provider linkages with immediate access changes.
Motivation & Context
While #1314 and #1317 (OAuth connect/disconnect hooks) were tested at the repository layer, we need confidence that the wiring between
crc,connected_services, and Authz/SpiceDB holds up through the actual HTTP API. These tests simulate real user journeys:Design Decisions & Rationale
1. Test Through the Real HTTP Surface
Rather than calling repository methods directly, these tests use
SanicASGITestClientto hit the actual endpoints (POST /api/data/resource_pools,GET /api/data/oauth2/providers/{id}/authorize,GET /api/data/oauth2/callback, etc.). This validates:ConnectedServicesRepository._on_oauth2_connectedis actually invoked from the callback handler).GET /api/data/resource_poolsfilters based on SpiceDB relations).2. Reuse the Dummy OAuth Client
Tests in
test_resource_pools.pypatchapp_manager_instance.oauth_http_client_factory.create_client = create_dummy_oauth_clientto avoid real external OAuth exchanges. This is the same pattern already used intest_connected_services.pyand keeps the tests fast, deterministic, and offline.3. Shared Helper for OAuth Flow Completion
A local helper
_complete_oauth_flow(test_client, provider_id, user_headers)was added intest_resource_pools.pyto avoid duplication across the three new tests. It performs the authorize → extract state → callback dance that the dummy OAuth client requires.4. Isolation via
xdist_group("sessions")Resource pool API tests are marked with
@pytest.mark.xdist_group("sessions")to prevent parallel test interference on shared database/cluster state. This follows the existing convention in the test file.5. Explicit Migration Call
test_connected_services.pytests callrun_migrations_for_app("common")at the start because they rely on the full application stack (including Authz/SpiceDB consistency) and theapp_manager_instancefixture. This matches patterns from earlier diffs.Changes
test/bases/renku_data_services/data_api/test_resource_pools.py_complete_oauth_flowhelper.test_post_resource_pool_with_remote_grants_connected_users:GET /resource_pools.test_delete_resource_pool_removes_access:test_patch_resource_pool_remote_change_swaps_access:test/bases/renku_data_services/data_api/test_connected_services.pyrun_migrations_for_app,KindCluster.test_oauth_callback_adds_user_to_rp:test_delete_oauth_connection_removes_rp_access:Behavioral Changes (Verified by Tests)
This PR contains no new production code; it only adds tests. However, it verifies the following behavioral changes introduced by #1314 and #1317:
Observable Behavior: OAuth Connection Drives RP Visibility
remote.provider_idmatches an OAuth provider they are connected to. This is visible at the API level viaGET /api/data/resource_pools.Observable Behavior: Disconnect Immediately Revokes Visibility
DELETE /api/data/oauth2/connections/{id}) immediately loses visibility of all resource pools tied to that provider.Observable Behavior: Provider Swap Atomically Exchanges Populations
remote.provider_idfrom P1 to P2 causes all connected P1 users to lose access and all connected P2 users to gain access in a single operation.PR Stack