Skip to content

Commit 83b8d99

Browse files
authored
Update MaaS subscription enforcement tests to use API key (#1199)
1 parent 5fe569b commit 83b8d99

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

tests/model_serving/model_server/maas_billing/maas_subscription/test_maas_sub_enforcement.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from simple_logger.logger import get_logger
66

77
from tests.model_serving.model_server.maas_billing.maas_subscription.utils import chat_payload_for_url
8-
from tests.model_serving.model_server.maas_billing.utils import build_maas_headers
98

109
LOGGER = get_logger(name=__name__)
1110

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

29-
@pytest.mark.sanity
28+
@pytest.mark.smoke
3029
@pytest.mark.parametrize("ocp_token_for_actor", [{"type": "premium"}], indirect=True)
3130
def test_subscribed_user_gets_200(
3231
self,
3332
request_session_http: requests.Session,
3433
model_url_tinyllama_premium: str,
35-
ocp_token_for_actor: str,
34+
maas_headers_for_actor_api_key: dict[str, str],
3635
) -> None:
3736
resp = request_session_http.post(
3837
url=model_url_tinyllama_premium,
39-
headers=build_maas_headers(token=ocp_token_for_actor),
38+
headers=maas_headers_for_actor_api_key,
4039
json=chat_payload_for_url(model_url=model_url_tinyllama_premium),
4140
timeout=60,
4241
)
4342
LOGGER.info(f"test_subscribed_user_gets_200 -> {resp.status_code}")
4443
assert resp.status_code == 200, f"Expected 200, got {resp.status_code}: {resp.text[:200]}"
4544

46-
@pytest.mark.sanity
45+
@pytest.mark.tier1
4746
@pytest.mark.parametrize("ocp_token_for_actor", [{"type": "premium"}], indirect=True)
4847
def test_explicit_subscription_header_works(
4948
self,
5049
request_session_http: requests.Session,
5150
model_url_tinyllama_premium: str,
52-
ocp_token_for_actor: str,
51+
maas_headers_for_actor_api_key: dict[str, str],
5352
maas_subscription_tinyllama_premium,
5453
) -> None:
5554
"""
5655
- Send valid x-maas-subscription
5756
- Expect 200
5857
"""
59-
headers = build_maas_headers(token=ocp_token_for_actor)
58+
headers = dict(maas_headers_for_actor_api_key)
6059
headers[MAAS_SUBSCRIPTION_HEADER] = maas_subscription_tinyllama_premium.name
6160

6261
resp = request_session_http.post(
@@ -69,19 +68,19 @@ def test_explicit_subscription_header_works(
6968

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

72-
@pytest.mark.sanity
71+
@pytest.mark.smoke
7372
@pytest.mark.parametrize("ocp_token_for_actor", [{"type": "premium"}], indirect=True)
7473
def test_invalid_subscription_header_gets_429(
7574
self,
7675
request_session_http: requests.Session,
7776
model_url_tinyllama_premium: str,
78-
ocp_token_for_actor: str,
77+
maas_headers_for_actor_api_key: dict[str, str],
7978
) -> None:
8079
"""
8180
- Send invalid x-maas-subscription
8281
- Expect 429 or 403
8382
"""
84-
headers = build_maas_headers(token=ocp_token_for_actor)
83+
headers = dict(maas_headers_for_actor_api_key)
8584
headers[MAAS_SUBSCRIPTION_HEADER] = INVALID_SUBSCRIPTION
8685

8786
resp = request_session_http.post(

0 commit comments

Comments
 (0)