test: add integration test for sharing

This commit is contained in:
Felix Spöttel
2023-06-29 14:59:43 +02:00
parent f01ea48f57
commit 05ebc17215
9 changed files with 236 additions and 219 deletions

View File

@@ -1,25 +1,18 @@
from fastapi.testclient import TestClient
from app.web.main import app
client = TestClient(app)
def test_authorization_header_missing() -> None:
def test_authorization_header_missing(client):
res = client.get("/api/v1/jobs")
assert res.status_code == 401
def test_authorization_header_malformed() -> None:
def test_authorization_header_malformed(client):
res = client.get("/api/v1/jobs", headers={"Authorization": "Bearer"})
assert res.status_code == 401
def test_incorrect_api_key() -> None:
def test_incorrect_api_key(client):
res = client.get("/api/v1/jobs", headers={"Authorization": "Bearer incorrect"})
assert res.status_code == 401
def test_existing_api_key(auth_headers: dict[str, str]) -> None:
def test_existing_api_key(client, auth_headers):
res = client.get("/api/v1/jobs", headers=auth_headers)
assert res.status_code == 200