Commit 48aba18
feat: add comprehensive e2e subscription flow tests with group support (opendatahub-io#468)
## Description
Add 11 new end-to-end tests in TestE2ESubscriptionFlow that validate the
complete subscription flow for MaaS, including both user-based and
group-based access patterns.
New E2E Tests (TestE2ESubscriptionFlow):
- User-based access (8 tests):
* Both auth and subscription → 200 OK
* Auth but no subscription → 403 Forbidden
* Subscription but no auth → 403 Forbidden
* Single subscription auto-select → 200 OK
* Multiple subscriptions without header → 403 Forbidden
* Multiple subscriptions with valid header → 200 OK
* Multiple subscriptions with invalid header → 403 Forbidden
* Multiple subscriptions with inaccessible header → 403 Forbidden
- Group-based access (3 tests):
* Group auth and subscription → 200 OK
* Group auth but no subscription → 403 Forbidden
* Group subscription but no auth → 403 Forbidden
Test Infrastructure Improvements:
- Add validation helpers (_get_auth_policies_for_model,
_get_subscriptions_for_model) to discover what resources exist and
improve debugging
- Add setup_class validation that fails fast with clear error messages
if prerequisites are missing (better CI feedback than skipping tests)
- Add _wait_for_maas_model_ready helper that waits for model
reconciliation and returns the actual endpoint URL
- All tests are self-contained: create their own resources, temporarily
remove shared resources when needed to isolate test conditions, and
restore everything in cleanup
Supporting Fixes:
- Fix smoke.sh: export GATEWAY_HOST so tests can run standalone
- Fix auth_utils.sh: correct DNS name extraction bug that caused
"maas-api.null.svc.cluster.local" errors
- Fix 6 pre-existing tests that incorrectly assumed admin user had
pre-configured access to models
- Fix test_delete_last_subscription: expect 403 (not 200) based on
actual system behavior when no subscriptions exist
- Update README: fix example test name and improve documentation
All tests handle Authorino's OR logic correctly (multiple auth policies/
subscriptions) by temporarily removing shared resources when testing
negative cases, ensuring proper test isolation.
## How Has This Been Tested?
Run the test suite using a ROSA cluster
## Merge criteria:
<!--- This PR will be merged by any repository approver when it meets
all the points in the checklist -->
<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] The commits are squashed in a cohesive manner and have meaningful
messages.
- [x] Testing instructions have been added in the PR body (for PRs
involving changes that are not immediately obvious).
- [x] The developer has manually tested the changes and verified that
the changes work
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Documentation**
* Added a "Running Tests Locally" guide covering environment setup,
variables, virtualenv, dependency install, pytest usage, CI notes, and
smoke-test steps.
* **Tests**
* Greatly expanded end-to-end subscription and authorization test suite,
covering header selection, multiple subscriptions, group/admin access,
reconciliation, and error cases.
* Added test helpers to create, wait for, query, and clean up test
resources (model refs, auth policies, subscriptions) and token handling.
* **Chores**
* Improved test scripts: derive/export gateway host and simplified MAAS
namespace handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 7195c0e commit 48aba18
File tree
4 files changed
+1055
-41
lines changed- test/e2e
- scripts
- tests
4 files changed
+1055
-41
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
227 | | - | |
228 | | - | |
| 226 | + | |
| 227 | + | |
229 | 228 | | |
230 | 229 | | |
231 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
68 | 73 | | |
| 74 | + | |
69 | 75 | | |
70 | 76 | | |
71 | 77 | | |
| |||
0 commit comments