Some checks failed
CI / Check (pull_request) Failing after 9m4s
CI / Detect Changes (pull_request) Has been skipped
CI / Deploy Agent (pull_request) Has been skipped
CI / Deploy Dashboard (pull_request) Has been skipped
CI / Deploy Docs (pull_request) Has been skipped
CI / Deploy MCP (pull_request) Has been skipped
E2E Tests: - 17 integration tests covering: health, repos CRUD, findings lifecycle, cascade delete (SAST + DAST + pentest), DAST targets, stats overview - TestServer harness: spins up agent API on random port with isolated MongoDB database per test, auto-cleanup - Added lib.rs to expose agent internals for integration tests - Nightly CI workflow with MongoDB service container (3 AM UTC) Tests verify: - Repository add/list/delete + duplicate rejection + invalid ID handling - Finding creation, filtering by severity/repo, status updates, bulk updates - Cascade delete: repo deletion removes all DAST targets, pentest sessions, attack chain nodes, DAST findings, SAST findings, and SBOM entries - DAST target CRUD and empty finding list - Stats overview accuracy with zero and populated data Also: - Fix Dockerfile.dashboard: bump dioxus-cli 0.7.3 → 0.7.4 (compile fix) - Fix clippy: allow new_without_default for pattern scanners Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
49 lines
1.4 KiB
Rust
49 lines
1.4 KiB
Rust
use crate::common::TestServer;
|
|
use serde_json::json;
|
|
|
|
#[tokio::test]
|
|
async fn add_and_list_dast_targets() {
|
|
let server = TestServer::start().await;
|
|
|
|
// Initially empty
|
|
let resp = server.get("/api/v1/dast/targets").await;
|
|
assert_eq!(resp.status(), 200);
|
|
let body: serde_json::Value = resp.json().await.unwrap();
|
|
assert_eq!(body["data"].as_array().unwrap().len(), 0);
|
|
|
|
// Add a target
|
|
let resp = server
|
|
.post(
|
|
"/api/v1/dast/targets",
|
|
&json!({
|
|
"name": "test-app",
|
|
"base_url": "https://test-app.example.com",
|
|
"target_type": "webapp",
|
|
}),
|
|
)
|
|
.await;
|
|
assert_eq!(resp.status(), 200);
|
|
|
|
// List should return 1
|
|
let resp = server.get("/api/v1/dast/targets").await;
|
|
let body: serde_json::Value = resp.json().await.unwrap();
|
|
let targets = body["data"].as_array().unwrap();
|
|
assert_eq!(targets.len(), 1);
|
|
assert_eq!(targets[0]["name"], "test-app");
|
|
assert_eq!(targets[0]["base_url"], "https://test-app.example.com");
|
|
|
|
server.cleanup().await;
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn list_dast_findings_empty() {
|
|
let server = TestServer::start().await;
|
|
|
|
let resp = server.get("/api/v1/dast/findings").await;
|
|
assert_eq!(resp.status(), 200);
|
|
let body: serde_json::Value = resp.json().await.unwrap();
|
|
assert_eq!(body["data"].as_array().unwrap().len(), 0);
|
|
|
|
server.cleanup().await;
|
|
}
|