-
Karel van Klink authored
Just use the oss-params-example.json from now on
Karel van Klink authoredJust use the oss-params-example.json from now on
test_subscriptions.py 1.30 KiB
from orchestrator.types import SubscriptionLifecycle
ROUTER_SUBSCRIPTION_ENDPOINT = "/api/v1/subscriptions/routers"
def test_router_subscriptions_endpoint_with_valid_api_key(test_client, nokia_router_subscription_factory):
nokia_router_subscription_factory()
nokia_router_subscription_factory()
nokia_router_subscription_factory()
nokia_router_subscription_factory(status=SubscriptionLifecycle.TERMINATED)
nokia_router_subscription_factory(status=SubscriptionLifecycle.INITIAL)
response = test_client.get(
ROUTER_SUBSCRIPTION_ENDPOINT, headers={"Authorization": "Bearer another_REALY_random_AND_3cure_T0keN"}
)
assert response.status_code == 200
assert len(response.json()) == 3
def test_router_subscriptions_endpoint_with_invalid_api_key(test_client, nokia_router_subscription_factory):
response = test_client.get(ROUTER_SUBSCRIPTION_ENDPOINT, headers={"Authorization": "Bearer fake_invalid_api_key"})
assert response.status_code == 403
assert response.json() == {"detail": "Invalid API Key"}
def test_router_subscriptions_endpoint_without_api_key(test_client, nokia_router_subscription_factory):
response = test_client.get(ROUTER_SUBSCRIPTION_ENDPOINT)
assert response.status_code == 403
assert response.json() == {"detail": "Not authenticated"}