Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from simple_logger.logger import get_logger

from tests.model_serving.model_server.maas_billing.maas_subscription.utils import chat_payload_for_url
from tests.model_serving.model_server.maas_billing.utils import build_maas_headers

LOGGER = get_logger(name=__name__)

Expand All @@ -26,37 +25,37 @@
class TestSubscriptionEnforcementTinyLlama:
"""Tests that MaaSSubscription correctly enforces subscription selection & limits."""

@pytest.mark.sanity
@pytest.mark.smoke
@pytest.mark.parametrize("ocp_token_for_actor", [{"type": "premium"}], indirect=True)
def test_subscribed_user_gets_200(
self,
request_session_http: requests.Session,
model_url_tinyllama_premium: str,
ocp_token_for_actor: str,
maas_headers_for_actor_api_key: dict[str, str],
) -> None:
resp = request_session_http.post(
url=model_url_tinyllama_premium,
headers=build_maas_headers(token=ocp_token_for_actor),
headers=maas_headers_for_actor_api_key,
json=chat_payload_for_url(model_url=model_url_tinyllama_premium),
timeout=60,
)
LOGGER.info(f"test_subscribed_user_gets_200 -> {resp.status_code}")
assert resp.status_code == 200, f"Expected 200, got {resp.status_code}: {resp.text[:200]}"

@pytest.mark.sanity
@pytest.mark.tier1
@pytest.mark.parametrize("ocp_token_for_actor", [{"type": "premium"}], indirect=True)
def test_explicit_subscription_header_works(
self,
request_session_http: requests.Session,
model_url_tinyllama_premium: str,
ocp_token_for_actor: str,
maas_headers_for_actor_api_key: dict[str, str],
maas_subscription_tinyllama_premium,
) -> None:
"""
- Send valid x-maas-subscription
- Expect 200
"""
headers = build_maas_headers(token=ocp_token_for_actor)
headers = dict(maas_headers_for_actor_api_key)
headers[MAAS_SUBSCRIPTION_HEADER] = maas_subscription_tinyllama_premium.name

resp = request_session_http.post(
Expand All @@ -69,19 +68,19 @@ def test_explicit_subscription_header_works(

assert resp.status_code == 200, f"Expected 200, got {resp.status_code}: {resp.text[:200]}"

@pytest.mark.sanity
@pytest.mark.smoke
@pytest.mark.parametrize("ocp_token_for_actor", [{"type": "premium"}], indirect=True)
def test_invalid_subscription_header_gets_429(
self,
request_session_http: requests.Session,
model_url_tinyllama_premium: str,
ocp_token_for_actor: str,
maas_headers_for_actor_api_key: dict[str, str],
) -> None:
"""
- Send invalid x-maas-subscription
- Expect 429 or 403
"""
headers = build_maas_headers(token=ocp_token_for_actor)
headers = dict(maas_headers_for_actor_api_key)
headers[MAAS_SUBSCRIPTION_HEADER] = INVALID_SUBSCRIPTION

resp = request_session_http.post(
Expand Down
Loading