diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-28 03:38:21 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-28 03:38:21 +0000 |
| commit | 3f74ababf338d65ac5e29e7eb5541ce416b7fe75 (patch) | |
| tree | 3e06696a1833db776a7d1908dd2812dcbe86f6a7 /grasp-audit/src/bin | |
| parent | c15215d704117d1035806e3b5f71afc19f5516a8 (diff) | |
add git http advertisment allow-reachable-sha1-in-want and allow-tip-sha1-in-want
Diffstat (limited to 'grasp-audit/src/bin')
| -rw-r--r-- | grasp-audit/src/bin/grasp-audit.rs | 54 |
1 files changed, 34 insertions, 20 deletions
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<()> { | |||
| 48 | 48 | ||
| 49 | match cli.command { | 49 | match cli.command { |
| 50 | Commands::Audit { relay, mode, spec, git_data_dir } => { | 50 | Commands::Audit { relay, mode, spec, git_data_dir } => { |
| 51 | // Early validation: check if --git-data-dir is required for the spec | ||
| 52 | let specs_requiring_git_dir = ["all", "git-clone", "push-auth", "repo-creation"]; | ||
| 53 | if specs_requiring_git_dir.contains(&spec.as_str()) && git_data_dir.is_none() { | ||
| 54 | return Err(anyhow!( | ||
| 55 | "The '{}' spec requires --git-data-dir to be specified.\n\ | ||
| 56 | \n\ | ||
| 57 | This directory should point to the relay's git data storage.\n\ | ||
| 58 | Example: --git-data-dir /path/to/relay/repos\n\ | ||
| 59 | \n\ | ||
| 60 | If using Docker, mount a volume and pass that path:\n\ | ||
| 61 | docker run -v /tmp/repos:/srv/ngit-relay/repos ...\n\ | ||
| 62 | cargo run -- audit --relay ws://localhost:8080 --git-data-dir /tmp/repos", | ||
| 63 | spec | ||
| 64 | )); | ||
| 65 | } | ||
| 66 | |||
| 51 | let mut config = match mode.as_str() { | 67 | let mut config = match mode.as_str() { |
| 52 | "ci" => AuditConfig::ci(), | 68 | "ci" => AuditConfig::ci(), |
| 53 | "production" => AuditConfig::production(), | 69 | "production" => AuditConfig::production(), |
| @@ -87,7 +103,7 @@ async fn main() -> Result<()> { | |||
| 87 | 103 | ||
| 88 | println!("✓ Connected\n"); | 104 | println!("✓ Connected\n"); |
| 89 | 105 | ||
| 90 | // Helper to check if git_data_dir is required | 106 | // Helper to check if git_data_dir is required for individual specs |
| 91 | let require_git_data_dir = |spec_name: &str| -> Result<PathBuf> { | 107 | let require_git_data_dir = |spec_name: &str| -> Result<PathBuf> { |
| 92 | git_data_dir.clone().ok_or_else(|| { | 108 | git_data_dir.clone().ok_or_else(|| { |
| 93 | anyhow!( | 109 | anyhow!( |
| @@ -130,6 +146,9 @@ async fn main() -> Result<()> { | |||
| 130 | specs::RepositoryCreationTests::run_all(&client, &dir).await | 146 | specs::RepositoryCreationTests::run_all(&client, &dir).await |
| 131 | } | 147 | } |
| 132 | "all" => { | 148 | "all" => { |
| 149 | // git_data_dir is guaranteed by early validation | ||
| 150 | let dir = git_data_dir.clone().expect("git_data_dir validated earlier"); | ||
| 151 | |||
| 133 | println!("Running all tests...\n"); | 152 | println!("Running all tests...\n"); |
| 134 | let mut all_results = AuditResult::new("All GRASP-01 Tests"); | 153 | let mut all_results = AuditResult::new("All GRASP-01 Tests"); |
| 135 | 154 | ||
| @@ -153,25 +172,20 @@ async fn main() -> Result<()> { | |||
| 153 | let cors_results = specs::CorsTests::run_all(&client, &relay_domain).await; | 172 | let cors_results = specs::CorsTests::run_all(&client, &relay_domain).await; |
| 154 | all_results.merge(cors_results); | 173 | all_results.merge(cors_results); |
| 155 | 174 | ||
| 156 | // Tests that require git_data_dir | 175 | // Git clone tests |
| 157 | if let Some(ref dir) = git_data_dir { | 176 | println!(" → Git clone tests..."); |
| 158 | // Git clone tests | 177 | let clone_results = specs::GitCloneTests::run_all(&client, &dir, &relay_domain).await; |
| 159 | println!(" → Git clone tests..."); | 178 | all_results.merge(clone_results); |
| 160 | let clone_results = specs::GitCloneTests::run_all(&client, dir, &relay_domain).await; | 179 | |
| 161 | all_results.merge(clone_results); | 180 | // Push authorization tests |
| 162 | 181 | println!(" → Push authorization tests..."); | |
| 163 | // Push authorization tests | 182 | let push_results = specs::PushAuthorizationTests::run_all(&client, &dir, &relay_domain).await; |
| 164 | println!(" → Push authorization tests..."); | 183 | all_results.merge(push_results); |
| 165 | let push_results = specs::PushAuthorizationTests::run_all(&client, dir, &relay_domain).await; | 184 | |
| 166 | all_results.merge(push_results); | 185 | // Repository creation tests |
| 167 | 186 | println!(" → Repository creation tests..."); | |
| 168 | // Repository creation tests | 187 | let repo_results = specs::RepositoryCreationTests::run_all(&client, &dir).await; |
| 169 | println!(" → Repository creation tests..."); | 188 | all_results.merge(repo_results); |
| 170 | let repo_results = specs::RepositoryCreationTests::run_all(&client, dir).await; | ||
| 171 | all_results.merge(repo_results); | ||
| 172 | } else { | ||
| 173 | println!(" ⚠ Skipping git-clone, push-auth, repo-creation tests (no --git-data-dir)"); | ||
| 174 | } | ||
| 175 | 189 | ||
| 176 | println!(); | 190 | println!(); |
| 177 | all_results | 191 | all_results |