<?xml version="1.0" encoding="utf-8"?><testsuites name="pytest tests"><testsuite name="pytest" errors="0" failures="5" skipped="1" tests="44" time="263.872" timestamp="2026-06-09T15:19:29.062624+00:00" hostname="maas-group-test-bs42d-e2e-maas-openshift-pod"><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyCRUD" name="test_create_api_key" time="0.112" /><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.100" /><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.099" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyBulkOperations" name="test_bulk_revoke_own_keys" time="0.256" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyBulkOperations" name="test_bulk_revoke_other_user_forbidden" time="0.038" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyBulkOperations" name="test_bulk_revoke_admin_can_revoke_any_user" time="0.099" /><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.031" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyExpiration" name="test_create_key_exceeds_expiration_limit" time="0.033" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyExpiration" name="test_create_key_without_expiration" time="0.033" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyExpiration" name="test_create_key_with_short_expiration" time="0.033" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_api_key_model_access_success" time="0.104" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_invalid_api_key_rejected" time="0.023" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_no_auth_header_rejected" time="0.020" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_revoked_api_key_rejected" time="2.119" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyModelInference" name="test_api_key_chat_completions" time="0.028" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyRevocationE2E" name="test_double_revoke_returns_404" time="0.100" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyRevocationE2E" name="test_revoke_nonexistent_key_returns_404" time="0.035" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyRevocationE2E" name="test_revoke_then_create_new_key_works" time="0.160" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyRevocationE2E" name="test_individual_revoke_multiple_keys" time="0.248" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeyRevocationE2E" name="test_revoke_keys_rejected_at_gateway" time="0.313" /><testcase classname="test.e2e.tests.test_api_keys.TestEphemeralKeyCleanup" name="test_cronjob_exists_and_configured" time="0.107" /><testcase classname="test.e2e.tests.test_api_keys.TestEphemeralKeyCleanup" name="test_cleanup_networkpolicy_exists" time="0.111" /><testcase classname="test.e2e.tests.test_api_keys.TestEphemeralKeyCleanup" name="test_create_ephemeral_key" time="0.104" /><testcase classname="test.e2e.tests.test_api_keys.TestEphemeralKeyCleanup" name="test_trigger_cleanup_preserves_active_keys" time="0.503" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_create_key_for_active_subscription" time="11.466" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_create_key_for_degraded_subscription" time="19.212" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_create_key_for_failed_subscription" time="19.347" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_create_key_for_pending_subscription" time="19.314"><failure message="RuntimeError: Failed to create API key: 500">self = &lt;test_api_keys.TestAPIKeySubscriptionPhases object at 0x7f63717f1d90&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:1334: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

oc_token = 'eyJhbGciOiJSUzI1NiIsImtpZCI6IlVWalJWR0tBQlo3c2FlWGNDVjAtemE3ZmNpQkgwY21LZDM4ODlpb21nR1kifQ.eyJhdWQiOlsiaHR0cHM6Ly9wcm...S-arJeu-tOPdwdRECCMdAu3qbe9dLRGdWLsBx9iuJZKHMlONagj5H7SAfQyvO1kN9_y5_kXlRKm_plexGrksn0_tBMVMhbGZ-HQ-zvl_GxI6NsaDXgUDCQ'
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:246: RuntimeError</failure></testcase><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionPhases" name="test_reject_key_for_unreconciled_subscription" time="23.135"><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 0x7f63717f1d60&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:1414: AssertionError</failure></testcase><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionFilter" name="test_search_filters_by_subscription" time="10.172" /><testcase classname="test.e2e.tests.test_api_keys.TestAPIKeySubscriptionFilter" name="test_search_without_subscription_returns_all" time="0.181" /><testcase classname="test.e2e.tests.test_namespace_scoping.TestMaaSAPIWatchNamespace" name="test_subscription_in_subscription_namespace_visible_to_api" time="8.532" /><testcase classname="test.e2e.tests.test_namespace_scoping.TestMaaSAPIWatchNamespace" name="test_subscription_in_another_namespace_not_visible_to_api" time="22.554" /><testcase classname="test.e2e.tests.test_namespace_scoping.TestMaaSControllerWatchNamespace" name="test_authpolicy_and_subscription_in_maas_subscription_namespace" time="24.032" /><testcase classname="test.e2e.tests.test_namespace_scoping.TestMaaSControllerWatchNamespace" name="test_authpolicy_and_subscription_in_another_namespace" time="29.821" /><testcase classname="test.e2e.tests.test_namespace_scoping.TestModelRef" name="test_auth_policy_model_ref" time="30.839" /><testcase classname="test.e2e.tests.test_namespace_scoping.TestModelRef" name="test_subscription_model_ref" time="30.763" /><testcase classname="test.e2e.tests.test_negative_security.TestHeaderSpoofing" name="test_injected_identity_headers_ignored" time="0.033"><failure message="RuntimeError: Failed to create API key: 500">self = &lt;test_negative_security.TestHeaderSpoofing object at 0x7f63713f68e0&gt;

    def test_injected_identity_headers_ignored(self):
        """Client injects X-MaaS-Username/Group/Key-Id — platform ignores them.
    
        Validates that Authorino strips attacker-controlled identity headers.
        The request should succeed (200) using the real key-derived identity,
        proving the spoofed headers had no effect on authorization.
        """
&gt;       api_key = _create_api_key(_get_cluster_token(), subscription=SIMULATOR_SUBSCRIPTION)

test/e2e/tests/test_negative_security.py:83: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

oc_token = 'eyJhbGciOiJSUzI1NiIsImtpZCI6IlVWalJWR0tBQlo3c2FlWGNDVjAtemE3ZmNpQkgwY21LZDM4ODlpb21nR1kifQ.eyJhdWQiOlsiaHR0cHM6Ly9wcm...dHJW02kAuKd2oLkTYCp8_A5eEYLPJgRz3s2cJJ95S3I1D6M8VRLuSX0ooRfgdyF_TEwXiuBlHBQ8vY77cAzZ4UaWuINQ6c7gOgd5kuoGvueiAzC1C2eHmA'
name = None, subscription = 'simulator-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:246: RuntimeError</failure></testcase><testcase classname="test.e2e.tests.test_negative_security.TestHeaderSpoofing" name="test_duplicate_subscription_headers_ignored" time="0.032"><failure message="RuntimeError: Failed to create API key: 500">self = &lt;test_negative_security.TestHeaderSpoofing object at 0x7f63713f6b80&gt;

    def test_duplicate_subscription_headers_ignored(self):
        """Client sends multiple X-MaaS-Subscription headers — API key binding wins.
    
        For API key requests, the subscription is fixed at mint time.
        Duplicate or conflicting X-MaaS-Subscription headers must not override
        the key-derived subscription.
        """
&gt;       api_key = _create_api_key(_get_cluster_token(), subscription=SIMULATOR_SUBSCRIPTION)

test/e2e/tests/test_negative_security.py:108: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

oc_token = 'eyJhbGciOiJSUzI1NiIsImtpZCI6IlVWalJWR0tBQlo3c2FlWGNDVjAtemE3ZmNpQkgwY21LZDM4ODlpb21nR1kifQ.eyJhdWQiOlsiaHR0cHM6Ly9wcm...dHJW02kAuKd2oLkTYCp8_A5eEYLPJgRz3s2cJJ95S3I1D6M8VRLuSX0ooRfgdyF_TEwXiuBlHBQ8vY77cAzZ4UaWuINQ6c7gOgd5kuoGvueiAzC1C2eHmA'
name = None, subscription = 'simulator-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:246: RuntimeError</failure></testcase><testcase classname="test.e2e.tests.test_negative_security.TestExpiredKeyRejection" name="test_expired_key_rejected_at_gateway" time="0.027"><skipped type="pytest.skip" message="Could not create short-lived key: 500">/workspace/source/test/e2e/tests/test_negative_security.py:188: Could not create short-lived key: 500</skipped></testcase><testcase classname="test.e2e.tests.test_negative_security.TestCrossModelAccess" name="test_key_cannot_access_model_outside_subscription" time="0.032"><failure message="RuntimeError: Failed to create API key: 500">self = &lt;test_negative_security.TestCrossModelAccess object at 0x7f63713f6fa0&gt;

    def test_key_cannot_access_model_outside_subscription(self):
        """Key for model A cannot infer on model B outside its subscription.
    
        Uses the pre-deployed unconfigured model (a model with no subscription
        granting access to it) to test cross-model access denial.
        """
&gt;       api_key = _create_api_key(_get_cluster_token(), subscription=SIMULATOR_SUBSCRIPTION)

test/e2e/tests/test_negative_security.py:222: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

oc_token = 'eyJhbGciOiJSUzI1NiIsImtpZCI6IlVWalJWR0tBQlo3c2FlWGNDVjAtemE3ZmNpQkgwY21LZDM4ODlpb21nR1kifQ.eyJhdWQiOlsiaHR0cHM6Ly9wcm...dHJW02kAuKd2oLkTYCp8_A5eEYLPJgRz3s2cJJ95S3I1D6M8VRLuSX0ooRfgdyF_TEwXiuBlHBQ8vY77cAzZ4UaWuINQ6c7gOgd5kuoGvueiAzC1C2eHmA'
name = None, subscription = 'simulator-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:246: RuntimeError</failure></testcase></testsuite></testsuites>