<?xml version="1.0" encoding="utf-8"?><testsuites name="pytest tests"><testsuite name="pytest" errors="0" failures="5" skipped="2" tests="83" time="515.856" timestamp="2026-06-10T13:14:40.233019+00:00" hostname="maas-group-test-fg78h-e2e-maas-openshift-pod"><testcase classname="test.e2e.tests.test_tenant_health.TestTenantConditionValues" name="test_tenant_conditions_healthy" time="0.130" /><testcase classname="test.e2e.tests.test_tenant_health.TestTenantManagedResources" name="test_core_resources_exist[deployment-1]" time="0.109" /><testcase classname="test.e2e.tests.test_tenant_health.TestTenantManagedResources" name="test_core_resources_exist[service-1]" time="0.105" /><testcase classname="test.e2e.tests.test_tenant_health.TestTenantManagedResources" name="test_core_resources_exist[serviceaccount-1]" time="0.102" /><testcase classname="test.e2e.tests.test_tenant_health.TestTenantManagedResources" name="test_core_resources_exist[cronjob-1]" time="0.103" /><testcase classname="test.e2e.tests.test_tenant_health.TestTenantManagedResources" name="test_core_resources_exist[configmap-1]" time="0.108" /><testcase classname="test.e2e.tests.test_tenant_health.TestTenantManagedResources" name="test_core_resources_exist[networkpolicy-1]" time="0.102" /><testcase classname="test.e2e.tests.test_tenant_health.TestTenantManagedResources" name="test_httproute_exists" time="0.134" /><testcase classname="test.e2e.tests.test_tenant_health.TestTenantManagedResources" name="test_authpolicy_exists" time="0.263"><failure message="AssertionError: Expected &gt;= 1 AuthPolicy with label maas.opendatahub.io/tenant-name=default-tenant, found 0: []&#10;assert 0 &gt;= 1&#10; +  where 0 = len([])">self = &lt;test_tenant_health.TestTenantManagedResources object at 0x7fedb1c6c070&gt;

    def test_authpolicy_exists(self):
        """AuthPolicy must exist (may be in gateway namespace, not deployment namespace)."""
        items = _list_resources_by_label("authpolicy.kuadrant.io", namespace=DEPLOYMENT_NAMESPACE)
        if items:
            return
        items = _list_resources_by_label("authpolicy.kuadrant.io")
        assert items is not None, "AuthPolicy CRD (kuadrant.io) not available on cluster"
        names = [item["metadata"]["name"] for item in items]
&gt;       assert len(items) &gt;= 1, (
            f"Expected &gt;= 1 AuthPolicy with label {TENANT_LABEL_SELECTOR}, "
            f"found {len(items)}: {names}"
        )
E       AssertionError: Expected &gt;= 1 AuthPolicy with label maas.opendatahub.io/tenant-name=default-tenant, found 0: []
E       assert 0 &gt;= 1
E        +  where 0 = len([])

test/e2e/tests/test_tenant_health.py:219: AssertionError</failure></testcase><testcase classname="test.e2e.tests.test_tenant_health.TestTenantManagedResources" name="test_rbac_resources_exist[clusterrole-1]" time="0.107" /><testcase classname="test.e2e.tests.test_tenant_health.TestTenantManagedResources" name="test_rbac_resources_exist[clusterrolebinding-1]" time="0.102" /><testcase classname="test.e2e.tests.test_tenant_health.TestTenantManagedResources" name="test_monitoring_resources_exist" time="0.131" /><testcase classname="test.e2e.tests.test_tenant_health.TestTenantManagedResources" name="test_optional_resources_exist[persesdashboard.perses.dev-perses.dev-persesdashboards]" time="0.118"><skipped type="pytest.skip" message="CRD persesdashboards.perses.dev not registered on cluster">/workspace/source/test/e2e/tests/test_tenant_health.py:257: CRD persesdashboards.perses.dev not registered on cluster</skipped></testcase><testcase classname="test.e2e.tests.test_tenant_health.TestTenantManagedResources" name="test_optional_resources_exist[persesdatasource.perses.dev-perses.dev-persesdatasources]" time="0.108"><skipped type="pytest.skip" message="CRD persesdatasources.perses.dev not registered on cluster">/workspace/source/test/e2e/tests/test_tenant_health.py:257: CRD persesdatasources.perses.dev not registered on cluster</skipped></testcase><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyCRUD" name="test_create_api_key" time="0.099" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyCRUD" name="test_list_api_keys" time="0.131" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyCRUD" name="test_revoke_api_key" time="0.094" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyAuthorization" name="test_admin_manage_other_users_keys" time="0.122" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyAuthorization" name="test_non_admin_cannot_access_other_users_keys" time="0.091" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyBulkOperations" name="test_bulk_revoke_own_keys" time="0.223" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyBulkOperations" name="test_bulk_revoke_other_user_forbidden" time="0.027" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyBulkOperations" name="test_bulk_revoke_admin_can_revoke_any_user" time="0.088" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyExpiration" name="test_create_key_within_expiration_limit" time="0.029" /><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.029" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyExpiration" name="test_create_key_without_expiration" time="0.031" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyExpiration" name="test_create_key_with_short_expiration" time="0.029" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_api_key_model_access_success" time="0.098" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_invalid_api_key_rejected" time="0.021" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_no_auth_header_rejected" time="0.018" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_revoked_api_key_rejected" time="2.109" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_api_key_chat_completions" time="0.027" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyRevocationE2E" name="test_double_revoke_returns_404" time="0.097" /><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.138" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyRevocationE2E" name="test_individual_revoke_multiple_keys" time="0.185" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyRevocationE2E" name="test_revoke_keys_rejected_at_gateway" time="0.306" /><testcase classname="test.e2e.tests.test_api_keys.TestEphemeralKeyCleanup" name="test_cronjob_exists_and_configured" time="0.104" /><testcase classname="test.e2e.tests.test_api_keys.TestEphemeralKeyCleanup" name="test_cleanup_networkpolicy_exists" time="0.108" /><testcase classname="test.e2e.tests.test_api_keys.TestEphemeralKeyCleanup" name="test_create_ephemeral_key" time="0.101" /><testcase classname="test.e2e.tests.test_api_keys.TestEphemeralKeyCleanup" name="test_trigger_cleanup_preserves_active_keys" time="0.487" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_create_key_for_active_subscription" time="9.290" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_create_key_for_degraded_subscription" time="19.176" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_create_key_for_failed_subscription" time="19.307" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_create_key_for_pending_subscription" time="19.355"><failure message="RuntimeError: Failed to create API key: 500">self = &lt;test_api_keys.TestAPIKeySubscriptionPhases object at 0x7fedb1ca18b0&gt;

    def test_create_key_for_pending_subscription(self):
        """API key creation succeeds for Pending subscription."""
        ns = _ns()
        subscription_name = "e2e-apikey-pending-sub"
        auth_name = "e2e-apikey-pending-auth"
        sa_name = "e2e-apikey-pending-sa"
    
        try:
            oc_token = _create_sa_token(sa_name, namespace=MODEL_NAMESPACE)
            sa_user = _sa_to_user(sa_name, namespace=MODEL_NAMESPACE)
    
            _create_test_auth_policy(auth_name, MODEL_REF, users=[sa_user])
            _create_test_subscription(subscription_name, MODEL_REF, users=[sa_user])
            _wait_reconcile(seconds=10)
    
            # Patch to Pending phase
            patch_data = {
                "status": {
                    "phase": "Pending",
                    "conditions": [{
                        "type": "Ready",
                        "status": "False",
                        "reason": "Pending",
                        "message": "Reconciliation in progress",
                        "lastTransitionTime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
                    }],
                }
            }
    
            cmd = [
                "kubectl", "patch", "maassubscription", subscription_name,
                "-n", ns, "--type=merge", "--subresource=status",
                "-p", json.dumps(patch_data)
            ]
            result = subprocess.run(cmd, capture_output=True, text=True)
            assert result.returncode == 0, f"Failed to patch: {result.stderr}"
    
            cr = _get_cr("maassubscription", subscription_name, namespace=ns)
            phase = cr.get("status", {}).get("phase")
            assert phase == "Pending", f"Expected Pending, got {phase}"
    
            # Create API key (should succeed)
&gt;           api_key = _create_api_key(
                oc_token,
                name="pending-sub-test",
                subscription=subscription_name
            )

test/e2e/tests/test_api_keys.py:1328: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

oc_token = 'eyJhbGciOiJSUzI1NiIsImtpZCI6InBTc0xTSHJkYm9FZ0hVLXRDTFd5NHQ5Y3htWmU0QWY4d3VrSHJ2am1Vd3cifQ.eyJhdWQiOlsiaHR0cHM6Ly9wcm...L7EoRhvZK6tJ_Lq8f7Qn1YIRURpgqB0Ecd7e6_pPiVDBLlGv2gHDvQODXDk-k2lSmnNuBm9Txxn_2u7omLgWVJza5pzSnLQc25HAc-_ekZa_6hMpnc35gw'
name = 'pending-sub-test', subscription = 'e2e-apikey-pending-sub'

    def _create_api_key(oc_token: str, name: str = None, subscription: str = None) -&gt; str:
        """Create an API key using the MaaS API and return the plaintext key.
    
        Args:
            oc_token: OC token for authentication with maas-api
            name: Optional name for the key (auto-generated if not provided)
            subscription: Optional MaaSSubscription name to bind (highest-priority auto-bind if omitted)
    
        Returns:
            The plaintext API key (sk-oai-xxx format)
        """
        r = _create_api_key_raw(oc_token, name, subscription)
        if r.status_code not in (200, 201):
&gt;           raise RuntimeError(f"Failed to create API key: {r.status_code} {r.text}")
E           RuntimeError: Failed to create API key: 500

test/e2e/tests/test_helper.py:243: RuntimeError</failure></testcase><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_reject_key_for_unreconciled_subscription" time="22.435"><failure message="AssertionError: Expected 400 for unreconciled subscription, got 500: &#10;assert 500 == 400&#10; +  where 500 = &lt;Response [500]&gt;.status_code">self = &lt;test_api_keys.TestAPIKeySubscriptionPhases object at 0x7fedb1bbcf70&gt;

    def test_reject_key_for_unreconciled_subscription(self):
        """
        API key creation is rejected for unreconciled subscription (empty phase).
    
        Note: Temporarily sets webhook failurePolicy to Ignore to allow creating
        resources while controller is down, then restores to Fail.
        """
        ns = _ns()
        subscription_name = "e2e-apikey-unreconciled-sub"
        auth_name = "e2e-apikey-unreconciled-auth"
        sa_name = "e2e-apikey-unreconciled-sa"
        webhook_name = "maas-validating-webhook-configuration"
    
        try:
            # Create service account and get token
            oc_token = _create_sa_token(sa_name, namespace=MODEL_NAMESPACE)
            sa_user = _sa_to_user(sa_name, namespace=MODEL_NAMESPACE)
    
            # Temporarily set webhook failurePolicy to Ignore
            # This allows creates to succeed when controller/webhook is unavailable
            # Find webhook indices dynamically by name to avoid brittleness
            result = subprocess.run(
                ["oc", "get", "validatingwebhookconfiguration", webhook_name, "-o", "json"],
                capture_output=True, text=True, check=True
            )
            webhook_config = json.loads(result.stdout)
            patch_ops = []
            for idx, webhook in enumerate(webhook_config.get("webhooks", [])):
                if webhook.get("name") in ["vmaassubscription.kb.io", "vmaasauthpolicy.kb.io"]:
                    patch_ops.append({"op": "replace", "path": f"/webhooks/{idx}/failurePolicy", "value": "Ignore"})
    
            subprocess.run(
                ["oc", "patch", "validatingwebhookconfiguration", webhook_name,
                 "--type=json", "-p", json.dumps(patch_ops)],
                capture_output=True, text=True, check=True
            )
    
            # Scale down controller to prevent reconciliation
            _scale_controller_down()
    
            # Create resources (webhook unavailable but Ignore policy allows creates)
            _create_test_auth_policy(auth_name, MODEL_REF, users=[sa_user])
            _create_test_subscription(subscription_name, MODEL_REF, users=[sa_user])
    
            # Verify subscription is unreconciled (empty phase)
            cr = _get_cr("maassubscription", subscription_name, namespace=ns)
            phase = cr.get("status", {}).get("phase", "")
            assert phase == "", f"Expected empty phase, got: {phase}"
            log.info("✅ Subscription is unreconciled (empty phase)")
    
            # Try to create API key (should fail with 400)
            response = requests.post(
                f"{_maas_api_url()}/v1/api-keys",
                headers={
                    "Authorization": f"Bearer {oc_token}",
                    "Content-Type": "application/json"
                },
                json={
                    "name": "unreconciled-sub-test",
                    "subscription": subscription_name
                },
                timeout=TIMEOUT,
                verify=TLS_VERIFY,
            )
    
&gt;           assert response.status_code == 400, \
                f"Expected 400 for unreconciled subscription, got {response.status_code}: {response.text}"
E               AssertionError: Expected 400 for unreconciled subscription, got 500: 
E               assert 500 == 400
E                +  where 500 = &lt;Response [500]&gt;.status_code

test/e2e/tests/test_api_keys.py:1408: AssertionError</failure></testcase><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionFilter" name="test_search_filters_by_subscription" time="10.176" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionFilter" name="test_search_without_subscription_returns_all" time="0.169" /><testcase classname="test.e2e.tests.test_namespace_scoping.TestMaaSAPIWatchNamespace" name="test_subscription_in_subscription_namespace_visible_to_api" time="8.520" /><testcase classname="test.e2e.tests.test_namespace_scoping.TestMaaSAPIWatchNamespace" name="test_subscription_in_another_namespace_not_visible_to_api" time="22.330" /><testcase classname="test.e2e.tests.test_namespace_scoping.TestMaaSControllerWatchNamespace" name="test_authpolicy_and_subscription_in_maas_subscription_namespace" time="23.929" /><testcase classname="test.e2e.tests.test_namespace_scoping.TestMaaSControllerWatchNamespace" name="test_authpolicy_and_subscription_in_another_namespace" time="30.043" /><testcase classname="test.e2e.tests.test_namespace_scoping.TestModelRef" name="test_auth_policy_model_ref" time="31.356" /><testcase classname="test.e2e.tests.test_namespace_scoping.TestModelRef" name="test_subscription_model_ref" time="31.582" /><testcase classname="test.e2e.tests.test_negative_security.TestHeaderSpoofing" name="test_injected_identity_headers_ignored" time="0.091" /><testcase classname="test.e2e.tests.test_negative_security.TestHeaderSpoofing" name="test_duplicate_subscription_headers_ignored" time="0.065" /><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.050" /><testcase classname="test.e2e.tests.test_negative_security.TestAuthPolicyRemoval" name="test_authpolicy_deletion_revokes_access" time="5.024" /><testcase classname="test.e2e.tests.test_negative_security.TestMissingModelRef" name="test_subscription_with_nonexistent_model_ref" time="1.034" /><testcase classname="test.e2e.tests.test_negative_security.TestMissingModelRef" name="test_authpolicy_with_nonexistent_model_ref" time="2.763" /><testcase classname="test.e2e.tests.test_negative_security.TestHeaderAbuse" name="test_special_characters_in_subscription_header" time="0.151" /><testcase classname="test.e2e.tests.test_negative_security.TestWebhookValidation" name="test_subscription_rejected_in_unlabeled_namespace" time="6.291" /><testcase classname="test.e2e.tests.test_negative_security.TestWebhookValidation" name="test_authpolicy_rejected_in_unlabeled_namespace" time="6.180" /><testcase classname="test.e2e.tests.test_subscription.TestAuthEnforcement" name="test_authorized_user_gets_200" time="0.072" /><testcase classname="test.e2e.tests.test_subscription.TestAuthEnforcement" name="test_no_auth_gets_401" time="0.019" /><testcase classname="test.e2e.tests.test_subscription.TestAuthEnforcement" name="test_invalid_token_gets_403" time="0.018" /><testcase classname="test.e2e.tests.test_subscription.TestAuthEnforcement" name="test_wrong_group_gets_403" time="0.027" /><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.063" /><testcase classname="test.e2e.tests.test_subscription.TestAPIKeySubscriptionBinding" name="test_create_api_key_nonexistent_subscription_errors" time="0.249" /><testcase classname="test.e2e.tests.test_subscription.TestSubscriptionEnforcement" name="test_subscribed_user_gets_200" time="0.032" /><testcase classname="test.e2e.tests.test_subscription.TestSubscriptionEnforcement" name="test_auth_pass_no_subscription_gets_403" time="16.410" /><testcase classname="test.e2e.tests.test_subscription.TestSubscriptionEnforcement" name="test_rate_limit_exhaustion_gets_429" time="25.577" /><testcase classname="test.e2e.tests.test_subscription.TestSubscriptionEnforcement" name="test_models_endpoint_exempt_from_rate_limiting" time="25.131"><failure message="RuntimeError: Failed to create API key: 500">self = &lt;test_subscription.TestSubscriptionEnforcement object at 0x7fedb1b7e310&gt;

    def test_models_endpoint_exempt_from_rate_limiting(self):
        """
        Test that /v1/models endpoint remains accessible when token quota is exhausted.
    
        This verifies that users can discover model capabilities even when they've
        used all their inference tokens. The /v1/models endpoint is a discovery/metadata
        endpoint that does not consume tokens and should remain accessible.
    
        Ref: https://issues.redhat.com/browse/RHOAIENG-46770
    
        Test steps:
        1. Create subscription with very low token limit (15 tokens)
        2. Exhaust the limit with inference requests (5 requests × 3 tokens = 15)
        3. Verify inference requests get 429 (rate limited)
        4. Verify /v1/models endpoint still returns 200 (not rate limited)
        """
        # Use unconfigured model to isolate this test
        model_ref = UNCONFIGURED_MODEL_REF
        model_path = UNCONFIGURED_MODEL_PATH
    
        # Create unique subscription and auth policy names
        auth_policy_name = "e2e-models-exempt-test-auth"
        subscription_name = "e2e-models-exempt-test-subscription"
    
        # Very low limit for fast, deterministic test
        # With 3 token limit and max_tokens=1, we're guaranteed to exhaust quota within 5 requests
        # (even if each request uses exactly 1 token: 5 requests &gt; 3 token limit)
        token_limit = 3
        window = "1m"
        max_tokens = 1
    
        try:
            # 1. Create auth policy allowing system:authenticated
            _create_test_auth_policy(
                name=auth_policy_name,
                model_refs=[model_ref],
                groups=["system:authenticated"]
            )
            _wait_reconcile()
            _wait_for_maas_auth_policy_phase(auth_policy_name, timeout=90)
    
            # 2. Create subscription with low token limit
            _create_test_subscription(
                name=subscription_name,
                model_refs=[model_ref],
                groups=["system:authenticated"],
                token_limit=token_limit,
                window=window
            )
            _wait_reconcile()
            _wait_for_maas_subscription_phase(subscription_name, timeout=90)
    
            # Wait for TRLP to be created AND enforced by Kuadrant/Limitador
            _wait_for_token_rate_limit_policy(model_ref, model_namespace=MODEL_NAMESPACE, timeout=90)
    
            # 3. Create API key for this subscription
            oc_token = _get_cluster_token()
&gt;           api_key = _create_api_key(
                oc_token,
                name=f"e2e-models-exempt-{uuid.uuid4().hex[:8]}",
                subscription=subscription_name,
            )

test/e2e/tests/test_subscription.py:587: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

oc_token = 'eyJhbGciOiJSUzI1NiIsImtpZCI6InBTc0xTSHJkYm9FZ0hVLXRDTFd5NHQ5Y3htWmU0QWY4d3VrSHJ2am1Vd3cifQ.eyJhdWQiOlsiaHR0cHM6Ly9wcm...j1egy4xF0W-0eLz01MNPfiFIFaikeV6qfAouE5Cn0gU4GQ94ikz280MaQaq1dd08Hea0OIT9zD1PokVsV3mo-M4Wal0bwAzRGoFgCbQA1aeVvSglWPw4uQ'
name = 'e2e-models-exempt-096f4352'
subscription = 'e2e-models-exempt-test-subscription'

    def _create_api_key(oc_token: str, name: str = None, subscription: str = None) -&gt; str:
        """Create an API key using the MaaS API and return the plaintext key.
    
        Args:
            oc_token: OC token for authentication with maas-api
            name: Optional name for the key (auto-generated if not provided)
            subscription: Optional MaaSSubscription name to bind (highest-priority auto-bind if omitted)
    
        Returns:
            The plaintext API key (sk-oai-xxx format)
        """
        r = _create_api_key_raw(oc_token, name, subscription)
        if r.status_code not in (200, 201):
&gt;           raise RuntimeError(f"Failed to create API key: {r.status_code} {r.text}")
E           RuntimeError: Failed to create API key: 500

test/e2e/tests/test_helper.py:243: RuntimeError</failure></testcase><testcase classname="test.e2e.tests.test_subscription.TestMultipleSubscriptionsPerModel" name="test_user_in_one_of_two_subscriptions_gets_200" time="57.210" /><testcase classname="test.e2e.tests.test_subscription.TestMultipleAuthPoliciesPerModel" name="test_two_auth_policies_or_logic" time="16.811" /><testcase classname="test.e2e.tests.test_subscription.TestMultipleAuthPoliciesPerModel" name="test_delete_one_auth_policy_other_still_works" time="24.517" /><testcase classname="test.e2e.tests.test_subscription.TestCascadeDeletion" name="test_delete_subscription_rebuilds_trlp" time="8.543" /><testcase classname="test.e2e.tests.test_subscription.TestCascadeDeletion" name="test_trlp_persists_during_multi_subscription_deletion" time="33.426" /><testcase classname="test.e2e.tests.test_subscription.TestCascadeDeletion" name="test_delete_last_subscription_denies_access" time="8.550" /><testcase classname="test.e2e.tests.test_subscription.TestCascadeDeletion" name="test_unconfigured_model_denied_by_gateway_auth" time="0.499" /><testcase classname="test.e2e.tests.test_subscription.TestOrderingEdgeCases" name="test_subscription_before_auth_policy" time="16.688"><failure message="RuntimeError: Failed to create API key: 500">self = &lt;test_subscription.TestOrderingEdgeCases object at 0x7fedb1673190&gt;

    def test_subscription_before_auth_policy(self):
        """Create subscription first, then auth policy -&gt; should work once both exist."""
        ns = _ns()
        try:
            # Subscription CR must exist before minting a key bound to it
            _apply_cr({
                "apiVersion": "maas.opendatahub.io/v1alpha1",
                "kind": "MaaSSubscription",
                "metadata": {"name": "e2e-ordering-sub", "namespace": ns},
                "spec": {
                    "owner": {"groups": [{"name": "system:authenticated"}]},
                    "modelRefs": [{"name": PREMIUM_MODEL_REF, "namespace": MODEL_NAMESPACE, "tokenRateLimits": [{"limit": 100, "window": "1m"}]}],
                },
            })
            _wait_reconcile()
            _wait_for_maas_subscription_phase("e2e-ordering-sub", namespace=ns, timeout=90)
    
&gt;           api_key = _create_api_key(
                _get_cluster_token(),
                name=f"e2e-ordering-{uuid.uuid4().hex[:8]}",
                subscription="e2e-ordering-sub",
            )

test/e2e/tests/test_subscription.py:985: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

oc_token = 'eyJhbGciOiJSUzI1NiIsImtpZCI6InBTc0xTSHJkYm9FZ0hVLXRDTFd5NHQ5Y3htWmU0QWY4d3VrSHJ2am1Vd3cifQ.eyJhdWQiOlsiaHR0cHM6Ly9wcm...j1egy4xF0W-0eLz01MNPfiFIFaikeV6qfAouE5Cn0gU4GQ94ikz280MaQaq1dd08Hea0OIT9zD1PokVsV3mo-M4Wal0bwAzRGoFgCbQA1aeVvSglWPw4uQ'
name = 'e2e-ordering-1fa96989', subscription = 'e2e-ordering-sub'

    def _create_api_key(oc_token: str, name: str = None, subscription: str = None) -&gt; str:
        """Create an API key using the MaaS API and return the plaintext key.
    
        Args:
            oc_token: OC token for authentication with maas-api
            name: Optional name for the key (auto-generated if not provided)
            subscription: Optional MaaSSubscription name to bind (highest-priority auto-bind if omitted)
    
        Returns:
            The plaintext API key (sk-oai-xxx format)
        """
        r = _create_api_key_raw(oc_token, name, subscription)
        if r.status_code not in (200, 201):
&gt;           raise RuntimeError(f"Failed to create API key: {r.status_code} {r.text}")
E           RuntimeError: Failed to create API key: 500

test/e2e/tests/test_helper.py:243: RuntimeError</failure></testcase></testsuite></testsuites>