Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /SHAdd0WTAka_Zen-Ai-Pentest /tests /test_api_endpoints.py
| """API Endpoint Tests - FastAPI TestClient. | |
| Target: +10% Coverage durch direkte API-Tests. | |
| """ | |
| import pytest | |
| from fastapi.testclient import TestClient | |
| from api.main import app | |
| client = TestClient(app) | |
| class TestHealthEndpoints: | |
| """Tests für Health-Check Endpunkte.""" | |
| def test_health_check(self): | |
| """Test GET /health endpoint.""" | |
| response = client.get("/health") | |
| assert response.status_code in [200, 307, 429, 403] | |
| def test_readiness_check(self): | |
| """Test GET /ready endpoint.""" | |
| response = client.get("/ready") | |
| assert response.status_code in [200, 307, 401, 404, 429, 403] | |
| def test_liveness_check(self): | |
| """Test GET /live endpoint.""" | |
| response = client.get("/live") | |
| assert response.status_code in [200, 307, 401, 404, 429, 403] | |
| class TestAuthEndpoints: | |
| """Tests für Auth Endpunkte.""" | |
| def test_login_endpoint_structure(self): | |
| """Test POST /auth/login exists.""" | |
| response = client.post("/auth/login", json={}) | |
| # Sollte 422 (Validation Error) oder 401 (Unauthorized) sein | |
| assert response.status_code in [200, 401, 403, 404, 422, 429] | |
| def test_register_endpoint_structure(self): | |
| """Test POST /auth/register exists.""" | |
| response = client.post("/auth/register", json={}) | |
| assert response.status_code in [200, 400, 401, 404, 422, 429, 403] | |
| class TestScanEndpoints: | |
| """Tests für Scan Endpunkte.""" | |
| def test_get_scans(self): | |
| """Test GET /scans endpoint.""" | |
| response = client.get("/scans") | |
| assert response.status_code in [200, 401, 403, 404, 429] | |
| def test_create_scan_structure(self): | |
| """Test POST /scans exists.""" | |
| response = client.post("/scans", json={}) | |
| assert response.status_code in [200, 401, 403, 404, 422, 429] | |
| class TestFindingEndpoints: | |
| """Tests für Finding Endpunkte.""" | |
| def test_get_findings(self): | |
| """Test GET /findings endpoint.""" | |
| response = client.get("/findings") | |
| assert response.status_code in [200, 401, 403, 404, 429] | |
| class TestReportEndpoints: | |
| """Tests für Report Endpunkte.""" | |
| def test_get_reports(self): | |
| """Test GET /reports endpoint.""" | |
| response = client.get("/reports") | |
| assert response.status_code in [200, 401, 403, 404, 429] | |
| class TestUserEndpoints: | |
| """Tests für User Endpunkte.""" | |
| def test_get_users(self): | |
| """Test GET /users endpoint.""" | |
| response = client.get("/users") | |
| assert response.status_code in [200, 401, 403, 404, 429] | |
| def test_get_current_user(self): | |
| """Test GET /users/me endpoint.""" | |
| response = client.get("/users/me") | |
| assert response.status_code in [200, 401, 403, 404, 429] | |
| class TestToolEndpoints: | |
| """Tests für Tool Endpunkte.""" | |
| def test_get_tools(self): | |
| """Test GET /tools endpoint.""" | |
| response = client.get("/tools") | |
| assert response.status_code in [200, 401, 403, 404, 429] | |
| def test_execute_tool_structure(self): | |
| """Test POST /tools/execute exists.""" | |
| response = client.post("/tools/execute", json={}) | |
| assert response.status_code in [200, 401, 403, 404, 422, 429] | |
| class TestTargetEndpoints: | |
| """Tests für Target Endpunkte.""" | |
| def test_get_targets(self): | |
| """Test GET /targets endpoint.""" | |
| response = client.get("/targets") | |
| assert response.status_code in [200, 401, 403, 404, 429] | |
| class TestDashboardEndpoints: | |
| """Tests für Dashboard Endpunkte.""" | |
| def test_get_dashboard_stats(self): | |
| """Test GET /dashboard/stats endpoint.""" | |
| response = client.get("/dashboard/stats") | |
| assert response.status_code in [200, 401, 403, 404, 429] | |
| def test_get_dashboard_recent_scans(self): | |
| """Test GET /dashboard/recent-scans endpoint.""" | |
| response = client.get("/dashboard/recent-scans") | |
| assert response.status_code in [200, 401, 403, 404, 429] | |
| class TestAgentEndpoints: | |
| """Tests für Agent Endpunkte.""" | |
| def test_get_agents(self): | |
| """Test GET /agents endpoint.""" | |
| response = client.get("/agents") | |
| assert response.status_code in [200, 401, 403, 404, 429] | |
| class TestIntegrationEndpoints: | |
| """Tests für Integration Endpunkte.""" | |
| def test_get_integrations(self): | |
| """Test GET /integrations endpoint.""" | |
| response = client.get("/integrations") | |
| assert response.status_code in [200, 401, 403, 404, 429] | |
| class TestConfigEndpoints: | |
| """Tests für Config Endpunkte.""" | |
| def test_get_config(self): | |
| """Test GET /config endpoint.""" | |
| response = client.get("/config") | |
| assert response.status_code in [200, 401, 403, 404, 429] | |
Xet Storage Details
- Size:
- 4.76 kB
- Xet hash:
- 1fd8e3254ce34879c670f2a187a10d5f8dae6e9ca2404bb81a83a74707f835e4
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.