73 lines
1.8 KiB
Python
73 lines
1.8 KiB
Python
"""Tests for REST API endpoints."""
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_health(client):
|
|
resp = await client.get("/health")
|
|
assert resp.status_code == 200
|
|
assert resp.json()["status"] == "ok"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_list_scans_empty(client):
|
|
resp = await client.get("/api/v1/scans")
|
|
assert resp.status_code == 200
|
|
data = resp.json()
|
|
assert data["total"] == 0
|
|
assert len(data["scans"]) == 0
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_scan_stats_empty(client):
|
|
resp = await client.get("/api/v1/scans/stats")
|
|
assert resp.status_code == 200
|
|
data = resp.json()
|
|
assert data["total_scans"] == 0
|
|
assert data["flagged_scans"] == 0
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_scan_not_found(client):
|
|
resp = await client.get("/api/v1/scans/99999")
|
|
assert resp.status_code == 200
|
|
assert "detail" in resp.json()
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_list_packages_empty(client):
|
|
resp = await client.get("/api/v1/packages")
|
|
assert resp.status_code == 200
|
|
data = resp.json()
|
|
assert data["total"] == 0
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_list_findings_empty(client):
|
|
resp = await client.get("/api/v1/findings")
|
|
assert resp.status_code == 200
|
|
data = resp.json()
|
|
assert data["total"] == 0
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_web_ui_dashboard(client):
|
|
resp = await client.get("/")
|
|
assert resp.status_code == 200
|
|
assert "GuardDog Nexus" in resp.text
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_web_ui_scans(client):
|
|
resp = await client.get("/scans")
|
|
assert resp.status_code == 200
|
|
assert "Scans" in resp.text
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_web_ui_packages(client):
|
|
resp = await client.get("/packages")
|
|
assert resp.status_code == 200
|
|
assert "Packages" in resp.text
|