From 3f74ababf338d65ac5e29e7eb5541ce416b7fe75 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 28 Nov 2025 03:38:21 +0000 Subject: add git http advertisment allow-reachable-sha1-in-want and allow-tip-sha1-in-want --- grasp-audit/src/bin/grasp-audit.rs | 54 ++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 20 deletions(-) (limited to 'grasp-audit/src/bin') diff --git a/grasp-audit/src/bin/grasp-audit.rs b/grasp-audit/src/bin/grasp-audit.rs index 760ed55..c0a9273 100644 --- a/grasp-audit/src/bin/grasp-audit.rs +++ b/grasp-audit/src/bin/grasp-audit.rs @@ -48,6 +48,22 @@ async fn main() -> Result<()> { match cli.command { Commands::Audit { relay, mode, spec, git_data_dir } => { + // Early validation: check if --git-data-dir is required for the spec + let specs_requiring_git_dir = ["all", "git-clone", "push-auth", "repo-creation"]; + if specs_requiring_git_dir.contains(&spec.as_str()) && git_data_dir.is_none() { + return Err(anyhow!( + "The '{}' spec requires --git-data-dir to be specified.\n\ + \n\ + This directory should point to the relay's git data storage.\n\ + Example: --git-data-dir /path/to/relay/repos\n\ + \n\ + If using Docker, mount a volume and pass that path:\n\ + docker run -v /tmp/repos:/srv/ngit-relay/repos ...\n\ + cargo run -- audit --relay ws://localhost:8080 --git-data-dir /tmp/repos", + spec + )); + } + let mut config = match mode.as_str() { "ci" => AuditConfig::ci(), "production" => AuditConfig::production(), @@ -87,7 +103,7 @@ async fn main() -> Result<()> { println!("✓ Connected\n"); - // Helper to check if git_data_dir is required + // Helper to check if git_data_dir is required for individual specs let require_git_data_dir = |spec_name: &str| -> Result { git_data_dir.clone().ok_or_else(|| { anyhow!( @@ -130,6 +146,9 @@ async fn main() -> Result<()> { specs::RepositoryCreationTests::run_all(&client, &dir).await } "all" => { + // git_data_dir is guaranteed by early validation + let dir = git_data_dir.clone().expect("git_data_dir validated earlier"); + println!("Running all tests...\n"); let mut all_results = AuditResult::new("All GRASP-01 Tests"); @@ -153,25 +172,20 @@ async fn main() -> Result<()> { let cors_results = specs::CorsTests::run_all(&client, &relay_domain).await; all_results.merge(cors_results); - // Tests that require git_data_dir - if let Some(ref dir) = git_data_dir { - // Git clone tests - println!(" → Git clone tests..."); - let clone_results = specs::GitCloneTests::run_all(&client, dir, &relay_domain).await; - all_results.merge(clone_results); - - // Push authorization tests - println!(" → Push authorization tests..."); - let push_results = specs::PushAuthorizationTests::run_all(&client, dir, &relay_domain).await; - all_results.merge(push_results); - - // Repository creation tests - println!(" → Repository creation tests..."); - let repo_results = specs::RepositoryCreationTests::run_all(&client, dir).await; - all_results.merge(repo_results); - } else { - println!(" ⚠ Skipping git-clone, push-auth, repo-creation tests (no --git-data-dir)"); - } + // Git clone tests + println!(" → Git clone tests..."); + let clone_results = specs::GitCloneTests::run_all(&client, &dir, &relay_domain).await; + all_results.merge(clone_results); + + // Push authorization tests + println!(" → Push authorization tests..."); + let push_results = specs::PushAuthorizationTests::run_all(&client, &dir, &relay_domain).await; + all_results.merge(push_results); + + // Repository creation tests + println!(" → Repository creation tests..."); + let repo_results = specs::RepositoryCreationTests::run_all(&client, &dir).await; + all_results.merge(repo_results); println!(); all_results -- cgit v1.2.3