<?xml version="1.0" encoding="utf-8"?><testsuites name="pytest tests"><testsuite name="pytest" errors="0" failures="5" skipped="10" tests="113" time="732.182" timestamp="2026-07-09T04:28:10.803723+00:00" hostname="maas-group-test-g6w5v-e2e-maas-openshift-pod"><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyCRUD" name="test_create_api_key" time="0.094" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyCRUD" name="test_list_api_keys" time="0.133" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyCRUD" name="test_revoke_api_key" time="0.092" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyAuthorization" name="test_admin_manage_other_users_keys" time="0.131" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyAuthorization" name="test_non_admin_cannot_access_other_users_keys" time="0.092" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyBulkOperations" name="test_bulk_revoke_own_keys" time="0.249" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyBulkOperations" name="test_bulk_revoke_other_user_forbidden" time="0.031" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyBulkOperations" name="test_bulk_revoke_admin_can_revoke_any_user" time="0.089" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyExpiration" name="test_create_key_within_expiration_limit" time="0.032" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyExpiration" name="test_create_key_at_expiration_limit" time="0.033" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyExpiration" name="test_create_key_exceeds_expiration_limit" time="0.031" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyExpiration" name="test_create_key_without_expiration" time="0.030" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyExpiration" name="test_create_key_with_short_expiration" time="0.030" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_api_key_model_access_success" time="0.107" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_invalid_api_key_rejected" time="0.025" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_no_auth_header_rejected" time="0.021" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_revoked_api_key_rejected" time="2.122" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_api_key_chat_completions" time="0.033" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyRevocationE2E" name="test_double_revoke_returns_404" time="0.093" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyRevocationE2E" name="test_revoke_nonexistent_key_returns_404" time="0.030" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyRevocationE2E" name="test_revoke_then_create_new_key_works" time="0.156" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyRevocationE2E" name="test_individual_revoke_multiple_keys" time="0.191" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyRevocationE2E" name="test_revoke_keys_rejected_at_gateway" time="0.284" /><testcase classname="test.e2e.tests.test_api_keys.TestEphemeralKeyCleanup" name="test_cronjob_exists_and_configured" time="0.116"><skipped type="pytest.skip" message="CronJob maas-api-key-cleanup not found in opendatahub: Error from server (NotFound): cronjobs.batch &quot;maas-api-key-cleanup&quot; not found">/workspace/source/test/e2e/tests/test_api_keys.py:930: CronJob maas-api-key-cleanup not found in opendatahub: Error from server (NotFound): cronjobs.batch "maas-api-key-cleanup" not found</skipped></testcase><testcase classname="test.e2e.tests.test_api_keys.TestEphemeralKeyCleanup" name="test_cleanup_networkpolicy_exists" time="0.118"><skipped type="pytest.skip" message="NetworkPolicy maas-api-cleanup-restrict not found in opendatahub: Error from server (NotFound): networkpolicies.networking.k8s.io &quot;maas-api-cleanup-restrict&quot; not found">/workspace/source/test/e2e/tests/test_api_keys.py:977: NetworkPolicy maas-api-cleanup-restrict not found in opendatahub: Error from server (NotFound): networkpolicies.networking.k8s.io "maas-api-cleanup-restrict" not found</skipped></testcase><testcase classname="test.e2e.tests.test_api_keys.TestEphemeralKeyCleanup" name="test_create_ephemeral_key" time="0.098" /><testcase classname="test.e2e.tests.test_api_keys.TestEphemeralKeyCleanup" name="test_trigger_cleanup_preserves_active_keys" time="0.146"><skipped type="pytest.skip" message="Cannot find maas-api pod in opendatahub: error: error executing jsonpath &quot;{.items[0].metadata.name}&quot;: Error executing template: array index out of bounds: index 0, length 0. Printing more information for debugging the template:&#10;&#09;template was:&#10;&#09;&#09;{.items[0].metadata.name}&#10;&#09;object given to jsonpath engine was:&#10;&#09;&#09;map[string]interface {}{&quot;apiVersion&quot;:&quot;v1&quot;, &quot;items&quot;:[]interface {}{}, &quot;kind&quot;:&quot;List&quot;, &quot;metadata&quot;:map[string]interface {}{&quot;resourceVersion&quot;:&quot;&quot;}}">/workspace/source/test/e2e/tests/test_api_keys.py:1096: Cannot find maas-api pod in opendatahub: error: error executing jsonpath "{.items[0].metadata.name}": Error executing template: array index out of bounds: index 0, length 0. Printing more information for debugging the template:
	template was:
		{.items[0].metadata.name}
	object given to jsonpath engine was:
		map[string]interface {}{"apiVersion":"v1", "items":[]interface {}{}, "kind":"List", "metadata":map[string]interface {}{"resourceVersion":""}}</skipped></testcase><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_create_key_for_active_subscription" time="5.330" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_create_key_for_degraded_subscription" time="15.201" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_create_key_for_failed_subscription" time="15.324" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_create_key_for_pending_subscription" time="15.339" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_reject_key_for_unreconciled_subscription" time="20.207" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionFilter" name="test_search_filters_by_subscription" time="8.460" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionFilter" name="test_search_without_subscription_returns_all" time="0.028"><failure message="AssertionError: Failed to create key: &#10;assert 403 in (200, 201)&#10; +  where 403 = &lt;Response [403]&gt;.status_code">self = &lt;test_api_keys.TestAPIKeySubscriptionFilter object at 0x7f6d40bb0a60&gt;
api_keys_base_url = 'https://maas.apps.7d1d1265-0d1b-4223-85d8-71b0313a0e1a.prod.konfluxeaas.com/maas-api/v1/api-keys'
headers = {'Authorization': 'Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6Ikw3Z3FvRF9RSld6ODI4LUE4eGpodHZTay1KUmt6QWtIdUhuQ0hpY3NsWGsifQ.e...OI88rHPf9Oxp_5kFLPSK6oSbiWbHm8VCgmfrUp5aYkuQu8Zf5iQxNTnS-elPmwO4SGrzEeTf1LhEYzEEQ', 'Content-Type': 'application/json'}

    def test_search_without_subscription_returns_all(self, api_keys_base_url: str, headers: dict):
        """Search without subscription filter returns keys across all subscriptions."""
        key_ids = []
        try:
            # Create keys with explicit subscription binding
            for i in range(2):
                r = requests.post(
                    api_keys_base_url,
                    headers=headers,
                    json={"name": f"e2e-nofilter-{i}", "subscription": SIMULATOR_SUBSCRIPTION},
                    timeout=TIMEOUT,
                    verify=TLS_VERIFY,
                )
&gt;               assert r.status_code in (200, 201), f"Failed to create key: {r.text}"
E               AssertionError: Failed to create key: 
E               assert 403 in (200, 201)
E                +  where 403 = &lt;Response [403]&gt;.status_code

test/e2e/tests/test_api_keys.py:1591: AssertionError</failure></testcase><testcase classname="test.e2e.tests.test_namespace_scoping.TestMaaSAPIWatchNamespace" name="test_subscription_in_subscription_namespace_visible_to_api" time="0.000"><skipped type="pytest.skip" message="test_namespace_scoping validates single-tenant dormant mode; skipped when ENABLE_TENANT_NAMESPACE_DISCOVERY=true">/workspace/source/test/e2e/tests/test_namespace_scoping.py:212: test_namespace_scoping validates single-tenant dormant mode; skipped when ENABLE_TENANT_NAMESPACE_DISCOVERY=true</skipped></testcase><testcase classname="test.e2e.tests.test_namespace_scoping.TestMaaSAPIWatchNamespace" name="test_subscription_in_another_namespace_not_visible_to_api" time="0.000"><skipped type="pytest.skip" message="test_namespace_scoping validates single-tenant dormant mode; skipped when ENABLE_TENANT_NAMESPACE_DISCOVERY=true">/workspace/source/test/e2e/tests/test_namespace_scoping.py:245: test_namespace_scoping validates single-tenant dormant mode; skipped when ENABLE_TENANT_NAMESPACE_DISCOVERY=true</skipped></testcase><testcase classname="test.e2e.tests.test_namespace_scoping.TestMaaSControllerWatchNamespace" name="test_authpolicy_and_subscription_in_maas_subscription_namespace" time="0.000"><skipped type="pytest.skip" message="test_namespace_scoping validates single-tenant dormant mode; skipped when ENABLE_TENANT_NAMESPACE_DISCOVERY=true">/workspace/source/test/e2e/tests/test_namespace_scoping.py:283: test_namespace_scoping validates single-tenant dormant mode; skipped when ENABLE_TENANT_NAMESPACE_DISCOVERY=true</skipped></testcase><testcase classname="test.e2e.tests.test_namespace_scoping.TestMaaSControllerWatchNamespace" name="test_authpolicy_and_subscription_in_another_namespace" time="0.000"><skipped type="pytest.skip" message="test_namespace_scoping validates single-tenant dormant mode; skipped when ENABLE_TENANT_NAMESPACE_DISCOVERY=true">/workspace/source/test/e2e/tests/test_namespace_scoping.py:320: test_namespace_scoping validates single-tenant dormant mode; skipped when ENABLE_TENANT_NAMESPACE_DISCOVERY=true</skipped></testcase><testcase classname="test.e2e.tests.test_namespace_scoping.TestModelRef" name="test_auth_policy_model_ref" time="0.000"><skipped type="pytest.skip" message="test_namespace_scoping validates single-tenant dormant mode; skipped when ENABLE_TENANT_NAMESPACE_DISCOVERY=true">/workspace/source/test/e2e/tests/test_namespace_scoping.py:377: test_namespace_scoping validates single-tenant dormant mode; skipped when ENABLE_TENANT_NAMESPACE_DISCOVERY=true</skipped></testcase><testcase classname="test.e2e.tests.test_namespace_scoping.TestModelRef" name="test_subscription_model_ref" time="0.000"><skipped type="pytest.skip" message="test_namespace_scoping validates single-tenant dormant mode; skipped when ENABLE_TENANT_NAMESPACE_DISCOVERY=true">/workspace/source/test/e2e/tests/test_namespace_scoping.py:453: test_namespace_scoping validates single-tenant dormant mode; skipped when ENABLE_TENANT_NAMESPACE_DISCOVERY=true</skipped></testcase><testcase classname="test.e2e.tests.test_negative_security.TestHeaderSpoofing" name="test_injected_identity_headers_ignored" time="0.087" /><testcase classname="test.e2e.tests.test_negative_security.TestHeaderSpoofing" name="test_duplicate_subscription_headers_ignored" time="0.070" /><testcase classname="test.e2e.tests.test_negative_security.TestExpiredKeyRejection" name="test_expired_key_rejected_at_gateway" time="5.073" /><testcase classname="test.e2e.tests.test_negative_security.TestCrossModelAccess" name="test_key_cannot_access_model_outside_subscription" time="0.065" /><testcase classname="test.e2e.tests.test_negative_security.TestAuthPolicyRemoval" name="test_authpolicy_deletion_revokes_access" time="0.835" /><testcase classname="test.e2e.tests.test_negative_security.TestMissingModelRef" name="test_subscription_with_nonexistent_model_ref" time="1.063" /><testcase classname="test.e2e.tests.test_negative_security.TestMissingModelRef" name="test_authpolicy_with_nonexistent_model_ref" time="0.697" /><testcase classname="test.e2e.tests.test_negative_security.TestHeaderAbuse" name="test_special_characters_in_subscription_header" time="0.168" /><testcase classname="test.e2e.tests.test_negative_security.TestWebhookValidation" name="test_subscription_rejected_in_unlabeled_namespace" time="6.030" /><testcase classname="test.e2e.tests.test_negative_security.TestWebhookValidation" name="test_authpolicy_rejected_in_unlabeled_namespace" time="6.059" /><testcase classname="test.e2e.tests.test_subscription.TestAuthEnforcement" name="test_authorized_user_gets_200" time="0.077" /><testcase classname="test.e2e.tests.test_subscription.TestAuthEnforcement" name="test_no_auth_gets_401" time="0.021" /><testcase classname="test.e2e.tests.test_subscription.TestAuthEnforcement" name="test_invalid_token_gets_403" time="0.042" /><testcase classname="test.e2e.tests.test_subscription.TestAuthEnforcement" name="test_wrong_group_gets_403" time="0.030" /><testcase classname="test.e2e.tests.test_subscription.TestAPIKeySubscriptionBinding" name="test_create_api_key_uses_highest_priority_subscription" time="0.300" /><testcase classname="test.e2e.tests.test_subscription.TestAPIKeySubscriptionBinding" name="test_create_api_key_with_explicit_simulator_subscription" time="0.067" /><testcase classname="test.e2e.tests.test_subscription.TestAPIKeySubscriptionBinding" name="test_create_api_key_nonexistent_subscription_errors" time="0.257" /><testcase classname="test.e2e.tests.test_subscription.TestSubscriptionEnforcement" name="test_subscribed_user_gets_200" time="0.035" /><testcase classname="test.e2e.tests.test_subscription.TestSubscriptionEnforcement" name="test_auth_pass_no_subscription_gets_403" time="8.424" /><testcase classname="test.e2e.tests.test_subscription.TestSubscriptionEnforcement" name="test_rate_limit_exhaustion_gets_429" time="19.846" /><testcase classname="test.e2e.tests.test_subscription.TestSubscriptionEnforcement" name="test_models_endpoint_exempt_from_rate_limiting" time="15.709" /><testcase classname="test.e2e.tests.test_subscription.TestMultipleSubscriptionsPerModel" name="test_user_in_one_of_two_subscriptions_gets_200" time="4.400" /><testcase classname="test.e2e.tests.test_subscription.TestMultipleAuthPoliciesPerModel" name="test_two_auth_policies_or_logic" time="10.829" /><testcase classname="test.e2e.tests.test_subscription.TestMultipleAuthPoliciesPerModel" name="test_delete_one_auth_policy_other_still_works" time="12.523" /><testcase classname="test.e2e.tests.test_subscription.TestCascadeDeletion" name="test_delete_subscription_rebuilds_trlp" time="4.522" /><testcase classname="test.e2e.tests.test_subscription.TestCascadeDeletion" name="test_trlp_persists_during_multi_subscription_deletion" time="17.323" /><testcase classname="test.e2e.tests.test_subscription.TestCascadeDeletion" name="test_delete_last_subscription_denies_access" time="4.620" /><testcase classname="test.e2e.tests.test_subscription.TestCascadeDeletion" name="test_unconfigured_model_denied_by_gateway_auth" time="0.534" /><testcase classname="test.e2e.tests.test_subscription.TestOrderingEdgeCases" name="test_subscription_before_auth_policy" time="15.736" /><testcase classname="test.e2e.tests.test_subscription.TestManagedAnnotation" name="test_authpolicy_managed_false_prevents_update" time="4.235"><skipped type="pytest.skip" message="gateway-only mode: per-model AuthPolicy is not created">/workspace/source/test/e2e/tests/test_subscription.py:1056: gateway-only mode: per-model AuthPolicy is not created</skipped></testcase><testcase classname="test.e2e.tests.test_subscription.TestManagedAnnotation" name="test_trlp_managed_false_prevents_update" time="13.054" /><testcase classname="test.e2e.tests.test_subscription.TestE2ESubscriptionFlow" name="test_e2e_with_both_access_and_subscription_gets_200" time="5.690" /><testcase classname="test.e2e.tests.test_subscription.TestE2ESubscriptionFlow" name="test_e2e_with_access_but_no_subscription_gets_403" time="9.226" /><testcase classname="test.e2e.tests.test_subscription.TestE2ESubscriptionFlow" name="test_e2e_with_subscription_but_no_access_gets_403" time="5.674" /><testcase classname="test.e2e.tests.test_subscription.TestE2ESubscriptionFlow" name="test_e2e_single_subscription_auto_selects" time="11.623" /><testcase classname="test.e2e.tests.test_subscription.TestE2ESubscriptionFlow" name="test_e2e_multiple_subscriptions_separate_keys_gets_200" time="9.535" /><testcase classname="test.e2e.tests.test_subscription.TestE2ESubscriptionFlow" name="test_e2e_mint_api_key_denied_for_inaccessible_subscription" time="9.733" /><testcase classname="test.e2e.tests.test_subscription.TestE2ESubscriptionFlow" name="test_e2e_group_based_access_gets_200" time="9.124" /><testcase classname="test.e2e.tests.test_subscription.TestE2ESubscriptionFlow" name="test_e2e_group_based_auth_but_no_subscription_gets_403" time="9.205" /><testcase classname="test.e2e.tests.test_subscription.TestE2ESubscriptionFlow" name="test_e2e_group_based_subscription_but_no_auth_gets_403" time="5.340" /><testcase classname="test.e2e.tests.test_subscription.TestStatusReporting" name="test_subscription_active_status_with_valid_model" time="5.246" /><testcase classname="test.e2e.tests.test_subscription.TestStatusReporting" name="test_subscription_failed_status_with_missing_model" time="4.789" /><testcase classname="test.e2e.tests.test_subscription.TestStatusReporting" name="test_authpolicy_active_status_with_valid_model" time="4.791" /><testcase classname="test.e2e.tests.test_subscription.TestStatusReporting" name="test_authpolicy_failed_status_with_missing_model" time="4.786" /><testcase classname="test.e2e.tests.test_subscription.TestStatusReporting" name="test_subscription_degraded_status_with_partial_models" time="5.128" /><testcase classname="test.e2e.tests.test_subscription.TestStatusReporting" name="test_subscription_degraded_trlp_blocks_inference" time="93.667" /><testcase classname="test.e2e.tests.test_subscription.TestStatusReporting" name="test_authpolicy_degraded_status_with_partial_models" time="4.800" /><testcase classname="test.e2e.tests.test_subscription.TestStatusReporting" name="test_subscription_status_transitions_on_model_deletion" time="16.430" /><testcase classname="test.e2e.tests.test_subscription.TestDegradedSubscriptionFiltering" name="test_degraded_healthy_model_allows_inference" time="15.261" /><testcase classname="test.e2e.tests.test_subscription.TestDegradedSubscriptionFiltering" name="test_failed_subscription_blocks_inference" time="15.556" /><testcase classname="test.e2e.tests.test_subscription.TestDegradedSubscriptionFiltering" name="test_models_endpoint_with_degraded_subscription_api_key" time="15.284" /><testcase classname="test.e2e.tests.test_subscription.TestDegradedSubscriptionFiltering" name="test_models_endpoint_with_degraded_subscription_kube_token" time="15.270" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_single_subscription_auto_select" time="14.396" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_explicit_subscription_header" time="8.768" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_empty_subscription_header_value" time="4.431" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_models_filtered_by_subscription" time="4.811" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_deduplication_same_model_multiple_refs" time="9.251" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_different_modelrefs_same_model_id" time="9.383" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_multiple_distinct_models_in_subscription" time="15.870" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_user_token_returns_all_models" time="12.837" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_user_token_with_subscription_header_filters" time="9.092" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_empty_model_list" time="11.240" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_response_schema_matches_openapi" time="4.435" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_model_metadata_preserved" time="4.422" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_api_key_scoped_to_subscription" time="9.255" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_api_key_with_deleted_subscription_403" time="13.249" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_api_key_with_inaccessible_subscription_403" time="9.486"><failure message="AssertionError: Expected 403 for subscription without access, got 200: {&quot;data&quot;:[{&quot;id&quot;:&quot;facebook/opt-125m&quot;,&quot;created&quot;:1783571941,&quot;object&quot;:&quot;model&quot;,&quot;owned_by&quot;:&quot;llm/facebook-opt-125m-simulated&quot;,&quot;kind&quot;:&quot;LLMInferenceService&quot;,&quot;url&quot;:&quot;https://maas-default-gateway-openshift-default.openshift-ingress.svc.cluster.local/llm/facebook-opt-125m-simulated&quot;,&quot;ready&quot;:true,&quot;modelDetails&quot;:{&quot;description&quot;:&quot;A simulated OPT-125M model for free-tier testing&quot;,&quot;displayName&quot;:&quot;Facebook OPT 125M (Simulated)&quot;},&quot;subscriptions&quot;:[{&quot;name&quot;:&quot;simulator-subscription&quot;,&quot;displayName&quot;:&quot;Simulator Subscription (Free)&quot;,&quot;description&quot;:&quot;Free-tier subscription with 100 tokens/min rate limit&quot;}]}],&quot;object&quot;:&quot;list&quot;}&#10;assert 200 == 403&#10; +  where 200 = &lt;Response [200]&gt;.status_code">self = &lt;test_models_endpoint.TestModelsEndpoint object at 0x7f6d4072e220&gt;

    def test_api_key_with_inaccessible_subscription_403(self):
        """
        Test: API key bound to a subscription the user no longer has access to.
    
        This tests an edge case where an API key was minted when the user had access
        to a subscription, but later the user's group membership changed and they
        lost access. The key still has the subscription bound.
    
        Expected: HTTP 403 with error type: permission_error
        """
        ns = _ns()
        auth_policy_name = "e2e-api-key-no-access-auth"
        subscription_name = "e2e-api-key-no-access-sub"
        sa_user = "e2e-api-key-user-sa"
        sa_other = "e2e-api-key-other-sa"
    
        try:
            # Create two service accounts
            oc_token_user = _create_sa_token(sa_user, namespace=ns)
            _ = _create_sa_token(sa_other, namespace=ns)
    
            user_principal = _sa_to_user(sa_user, namespace=ns)
            other_principal = _sa_to_user(sa_other, namespace=ns)
    
            # Create subscription accessible only to "other" user
            _create_test_auth_policy(auth_policy_name, MODEL_REF, users=[user_principal, other_principal])
            _create_test_subscription(subscription_name, MODEL_REF, users=[other_principal])
    
            _wait_reconcile()
    
            # User tries to query with their token but specifying the other user's subscription
            # This simulates what would happen if an API key was bound to a subscription
            # the user doesn't have access to
            log.info("Querying /v1/models with user token and inaccessible subscription")
            r = _request_with_gateway_retry(
                requests.get,
                f"{_maas_api_url()}/v1/models",
                headers={
                    "Authorization": f"Bearer {oc_token_user}",
                    "X-MaaS-Subscription": subscription_name,
                },
            )
    
            # Should return 403 because user doesn't have access to the subscription
&gt;           assert r.status_code == 403, \
                f"Expected 403 for subscription without access, got {r.status_code}: {r.text}"
E               AssertionError: Expected 403 for subscription without access, got 200: {"data":[{"id":"facebook/opt-125m","created":1783571941,"object":"model","owned_by":"llm/facebook-opt-125m-simulated","kind":"LLMInferenceService","url":"https://maas-default-gateway-openshift-default.openshift-ingress.svc.cluster.local/llm/facebook-opt-125m-simulated","ready":true,"modelDetails":{"description":"A simulated OPT-125M model for free-tier testing","displayName":"Facebook OPT 125M (Simulated)"},"subscriptions":[{"name":"simulator-subscription","displayName":"Simulator Subscription (Free)","description":"Free-tier subscription with 100 tokens/min rate limit"}]}],"object":"list"}
E               assert 200 == 403
E                +  where 200 = &lt;Response [200]&gt;.status_code

test/e2e/tests/test_models_endpoint.py:1564: AssertionError</failure></testcase><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_invalid_subscription_header_403" time="9.107"><failure message="AssertionError: Expected 403 for invalid subscription, got 200: {&quot;data&quot;:[{&quot;id&quot;:&quot;facebook/opt-125m&quot;,&quot;created&quot;:1783571950,&quot;object&quot;:&quot;model&quot;,&quot;owned_by&quot;:&quot;llm/facebook-opt-125m-simulated&quot;,&quot;kind&quot;:&quot;LLMInferenceService&quot;,&quot;url&quot;:&quot;https://maas-default-gateway-openshift-default.openshift-ingress.svc.cluster.local/llm/facebook-opt-125m-simulated&quot;,&quot;ready&quot;:true,&quot;modelDetails&quot;:{&quot;description&quot;:&quot;A simulated OPT-125M model for free-tier testing&quot;,&quot;displayName&quot;:&quot;Facebook OPT 125M (Simulated)&quot;},&quot;subscriptions&quot;:[{&quot;name&quot;:&quot;e2e-models-valid-sub&quot;},{&quot;name&quot;:&quot;simulator-subscription&quot;,&quot;displayName&quot;:&quot;Simulator Subscription (Free)&quot;,&quot;description&quot;:&quot;Free-tier subscription with 100 tokens/min rate limit&quot;}]}],&quot;object&quot;:&quot;list&quot;}&#10;assert 200 == 403&#10; +  where 200 = &lt;Response [200]&gt;.status_code">self = &lt;test_models_endpoint.TestModelsEndpoint object at 0x7f6d4040b220&gt;

    def test_invalid_subscription_header_403(self):
        """
        Test: User with valid subscriptions but providing an invalid/non-existent
        subscription in the header gets 403.
    
        Expected: HTTP 403 with error type: permission_error and message:
        "requested subscription not found".
        """
        ns = _ns()
        auth_policy_name = "e2e-models-invalid-sub-auth"
        subscription_name = "e2e-models-valid-sub"
        sa_name = "e2e-models-invalid-sub-sa"
    
        try:
            # Create service account and get OC token for maas-api
            oc_token = _create_sa_token(sa_name, namespace=ns)
            sa_user = _sa_to_user(sa_name, namespace=ns)
    
            # Create test resources - user has valid subscription
            _create_test_auth_policy(auth_policy_name, MODEL_REF, users=[sa_user])
            _create_test_subscription(subscription_name, MODEL_REF, users=[sa_user])
    
            _wait_reconcile()
    
            # Test: GET /v1/models WITH non-existent subscription header
            # Expected: 403 with "subscription not found" error
            invalid_sub = "nonexistent-subscription-xyz"
            log.info(f"Testing: GET /v1/models with invalid subscription header: {invalid_sub}")
            url = f"{_maas_api_url()}/v1/models"
            r = _request_with_gateway_retry(
                requests.get,
                url,
                headers={
                    "Authorization": f"Bearer {oc_token}",
                    "x-maas-subscription": invalid_sub,
                },
            )
    
&gt;           assert r.status_code == 403, f"Expected 403 for invalid subscription, got {r.status_code}: {r.text}"
E           AssertionError: Expected 403 for invalid subscription, got 200: {"data":[{"id":"facebook/opt-125m","created":1783571950,"object":"model","owned_by":"llm/facebook-opt-125m-simulated","kind":"LLMInferenceService","url":"https://maas-default-gateway-openshift-default.openshift-ingress.svc.cluster.local/llm/facebook-opt-125m-simulated","ready":true,"modelDetails":{"description":"A simulated OPT-125M model for free-tier testing","displayName":"Facebook OPT 125M (Simulated)"},"subscriptions":[{"name":"e2e-models-valid-sub"},{"name":"simulator-subscription","displayName":"Simulator Subscription (Free)","description":"Free-tier subscription with 100 tokens/min rate limit"}]}],"object":"list"}
E           assert 200 == 403
E            +  where 200 = &lt;Response [200]&gt;.status_code

test/e2e/tests/test_models_endpoint.py:1620: AssertionError</failure></testcase><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_access_denied_to_subscription_403" time="9.766"><failure message="AssertionError: Expected 403 for inaccessible subscription, got 200: {&quot;data&quot;:[{&quot;id&quot;:&quot;facebook/opt-125m&quot;,&quot;created&quot;:1783571959,&quot;object&quot;:&quot;model&quot;,&quot;owned_by&quot;:&quot;llm/facebook-opt-125m-simulated&quot;,&quot;kind&quot;:&quot;LLMInferenceService&quot;,&quot;url&quot;:&quot;https://maas-default-gateway-openshift-default.openshift-ingress.svc.cluster.local/llm/facebook-opt-125m-simulated&quot;,&quot;ready&quot;:true,&quot;modelDetails&quot;:{&quot;description&quot;:&quot;A simulated OPT-125M model for free-tier testing&quot;,&quot;displayName&quot;:&quot;Facebook OPT 125M (Simulated)&quot;},&quot;subscriptions&quot;:[{&quot;name&quot;:&quot;simulator-subscription&quot;,&quot;displayName&quot;:&quot;Simulator Subscription (Free)&quot;,&quot;description&quot;:&quot;Free-tier subscription with 100 tokens/min rate limit&quot;},{&quot;name&quot;:&quot;e2e-models-user-sub&quot;}]}],&quot;object&quot;:&quot;list&quot;}&#10;assert 200 == 403&#10; +  where 200 = &lt;Response [200]&gt;.status_code">self = &lt;test_models_endpoint.TestModelsEndpoint object at 0x7f6d4040b280&gt;

    def test_access_denied_to_subscription_403(self):
        """
        Test: Subscription exists but user is not in its MaaSAuthPolicy owner list.
        User requests that subscription via header.
    
        Expected: HTTP 403 with error type: permission_error and message:
        "access denied to requested subscription".
        """
        ns = _ns()
        auth_policy_name = "e2e-models-access-denied-auth"
        user_subscription = "e2e-models-user-sub"
        other_subscription = "e2e-models-other-sub"
        sa_user = "e2e-models-user-sa"
        sa_other = "e2e-models-other-sa"
    
        try:
            # Create two service accounts
            oc_token_user = _create_sa_token(sa_user, namespace=ns)
            _ = _create_sa_token(sa_other, namespace=ns)  # SA creation only - token unused
    
            user_principal = _sa_to_user(sa_user, namespace=ns)
            other_principal = _sa_to_user(sa_other, namespace=ns)
    
            # Create test resources
            # Both users have access to the model via auth policy
            _create_test_auth_policy(auth_policy_name, MODEL_REF, users=[user_principal, other_principal])
            # Each user has their own subscription
            _create_test_subscription(user_subscription, MODEL_REF, users=[user_principal])
            _create_test_subscription(other_subscription, MODEL_REF, users=[other_principal])
    
            _wait_reconcile()
    
            # Test: User tries to use another user's subscription in header
            # Expected: 403 with "access denied" error
            log.info(f"Testing: GET /v1/models with inaccessible subscription: {other_subscription}")
            url = f"{_maas_api_url()}/v1/models"
            r = _request_with_gateway_retry(
                requests.get,
                url,
                headers={
                    "Authorization": f"Bearer {oc_token_user}",
                    "x-maas-subscription": other_subscription,
                },
            )
    
&gt;           assert r.status_code == 403, f"Expected 403 for inaccessible subscription, got {r.status_code}: {r.text}"
E           AssertionError: Expected 403 for inaccessible subscription, got 200: {"data":[{"id":"facebook/opt-125m","created":1783571959,"object":"model","owned_by":"llm/facebook-opt-125m-simulated","kind":"LLMInferenceService","url":"https://maas-default-gateway-openshift-default.openshift-ingress.svc.cluster.local/llm/facebook-opt-125m-simulated","ready":true,"modelDetails":{"description":"A simulated OPT-125M model for free-tier testing","displayName":"Facebook OPT 125M (Simulated)"},"subscriptions":[{"name":"simulator-subscription","displayName":"Simulator Subscription (Free)","description":"Free-tier subscription with 100 tokens/min rate limit"},{"name":"e2e-models-user-sub"}]}],"object":"list"}
E           assert 200 == 403
E            +  where 200 = &lt;Response [200]&gt;.status_code

test/e2e/tests/test_models_endpoint.py:1687: AssertionError</failure></testcase><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_api_key_ignores_subscription_header" time="16.404" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_multiple_api_keys_different_subscriptions" time="16.528" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_service_account_token_multiple_subs_no_header" time="12.597" /><testcase classname="test.e2e.tests.test_models_endpoint.TestModelsEndpoint" name="test_service_account_token_multiple_subs_with_header" time="12.595"><failure message="AssertionError: Should NOT see test/e2e-distinct-model-2 from e2e-sa-multi-hdr-sub2&#10;assert 'test/e2e-distinct-model-2' not in {'facebook/opt-125m', 'test/e2e-distinct-model', 'test/e2e-distinct-model-2'}">self = &lt;test_models_endpoint.TestModelsEndpoint object at 0x7f6d4072e2b0&gt;

    def test_service_account_token_multiple_subs_with_header(self):
        """
        Test: K8s token with access to multiple subscriptions filters by header.
    
        Creates a service account with access to two subscriptions. When querying
        with x-maas-subscription header, should return models from only the specified
        subscription.
    
        Expected: HTTP 200 with models from only the specified subscription.
        """
        sa_name = "e2e-sa-multi-subs-with-header"
        sa_ns = "default"
        maas_ns = _ns()
        sub1_name = "e2e-sa-multi-hdr-sub1"
        sub2_name = "e2e-sa-multi-hdr-sub2"
        auth1_name = "e2e-sa-multi-hdr-auth1"
        auth2_name = "e2e-sa-multi-hdr-auth2"
    
        try:
            # Create SA
            sa_token = _create_sa_token(sa_name, namespace=sa_ns)
            sa_user = _sa_to_user(sa_name, namespace=sa_ns)
    
            # Create two subscriptions with different models
            log.info(f"Creating subscription 1 with {DISTINCT_MODEL_REF}")
            _create_test_auth_policy(auth1_name, DISTINCT_MODEL_REF, users=[sa_user])
            _create_test_subscription(sub1_name, DISTINCT_MODEL_REF, users=[sa_user])
    
            log.info(f"Creating subscription 2 with {DISTINCT_MODEL_2_REF}")
            _create_test_auth_policy(auth2_name, DISTINCT_MODEL_2_REF, users=[sa_user])
            _create_test_subscription(sub2_name, DISTINCT_MODEL_2_REF, users=[sa_user])
    
            _wait_for_maas_auth_policy_phase(auth1_name)
            _wait_for_maas_auth_policy_phase(auth2_name)
            _wait_for_maas_subscription_phase(sub1_name)
            _wait_for_maas_subscription_phase(sub2_name)
    
            # Query with K8s token and header specifying sub1
            log.info(f"Querying /v1/models with K8s token and header: {sub1_name}")
            r1 = _request_with_gateway_retry(
                requests.get,
                f"{_maas_api_url()}/v1/models",
                headers={
                    "Authorization": f"Bearer {sa_token}",
                    "x-maas-subscription": sub1_name,
                },
            )
    
            assert r1.status_code == 200, f"Expected 200, got {r1.status_code}: {r1.text}"
            models1 = r1.json().get("data") or []
            model_ids1 = {m["id"] for m in models1}
    
            # Should see only models from sub1
            assert DISTINCT_MODEL_ID in model_ids1, f"Should see {DISTINCT_MODEL_ID} from {sub1_name}"
&gt;           assert DISTINCT_MODEL_2_ID not in model_ids1, f"Should NOT see {DISTINCT_MODEL_2_ID} from {sub2_name}"
E           AssertionError: Should NOT see test/e2e-distinct-model-2 from e2e-sa-multi-hdr-sub2
E           assert 'test/e2e-distinct-model-2' not in {'facebook/opt-125m', 'test/e2e-distinct-model', 'test/e2e-distinct-model-2'}

test/e2e/tests/test_models_endpoint.py:2013: AssertionError</failure></testcase></testsuite></testsuites>