diff options
Diffstat (limited to 'grasp-audit/src/bin/grasp-audit.rs')
| -rw-r--r-- | grasp-audit/src/bin/grasp-audit.rs | 43 |
1 files changed, 6 insertions, 37 deletions
diff --git a/grasp-audit/src/bin/grasp-audit.rs b/grasp-audit/src/bin/grasp-audit.rs index c0a9273..29f9c9a 100644 --- a/grasp-audit/src/bin/grasp-audit.rs +++ b/grasp-audit/src/bin/grasp-audit.rs | |||
| @@ -48,21 +48,6 @@ 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 | ||
| 67 | let mut config = match mode.as_str() { | 52 | let mut config = match mode.as_str() { |
| 68 | "ci" => AuditConfig::ci(), | 53 | "ci" => AuditConfig::ci(), |
| @@ -103,16 +88,6 @@ async fn main() -> Result<()> { | |||
| 103 | 88 | ||
| 104 | println!("✓ Connected\n"); | 89 | println!("✓ Connected\n"); |
| 105 | 90 | ||
| 106 | // Helper to check if git_data_dir is required for individual specs | ||
| 107 | let require_git_data_dir = |spec_name: &str| -> Result<PathBuf> { | ||
| 108 | git_data_dir.clone().ok_or_else(|| { | ||
| 109 | anyhow!( | ||
| 110 | "The '{}' spec requires --git-data-dir to be specified", | ||
| 111 | spec_name | ||
| 112 | ) | ||
| 113 | }) | ||
| 114 | }; | ||
| 115 | |||
| 116 | let results = match spec.as_str() { | 91 | let results = match spec.as_str() { |
| 117 | "nip01-smoke" => { | 92 | "nip01-smoke" => { |
| 118 | println!("Running NIP-01 smoke tests...\n"); | 93 | println!("Running NIP-01 smoke tests...\n"); |
| @@ -131,24 +106,18 @@ async fn main() -> Result<()> { | |||
| 131 | specs::CorsTests::run_all(&client, &relay_domain).await | 106 | specs::CorsTests::run_all(&client, &relay_domain).await |
| 132 | } | 107 | } |
| 133 | "git-clone" => { | 108 | "git-clone" => { |
| 134 | let dir = require_git_data_dir("git-clone")?; | ||
| 135 | println!("Running Git clone tests...\n"); | 109 | println!("Running Git clone tests...\n"); |
| 136 | specs::GitCloneTests::run_all(&client, &dir, &relay_domain).await | 110 | specs::GitCloneTests::run_all(&client, &relay_domain).await |
| 137 | } | 111 | } |
| 138 | "push-auth" => { | 112 | "push-auth" => { |
| 139 | let dir = require_git_data_dir("push-auth")?; | ||
| 140 | println!("Running push authorization tests...\n"); | 113 | println!("Running push authorization tests...\n"); |
| 141 | specs::PushAuthorizationTests::run_all(&client, &dir, &relay_domain).await | 114 | specs::PushAuthorizationTests::run_all(&client, &relay_domain).await |
| 142 | } | 115 | } |
| 143 | "repo-creation" => { | 116 | "repo-creation" => { |
| 144 | let dir = require_git_data_dir("repo-creation")?; | ||
| 145 | println!("Running repository creation tests...\n"); | 117 | println!("Running repository creation tests...\n"); |
| 146 | specs::RepositoryCreationTests::run_all(&client, &dir).await | 118 | specs::RepositoryCreationTests::run_all(&client, &relay_domain).await |
| 147 | } | 119 | } |
| 148 | "all" => { | 120 | "all" => { |
| 149 | // git_data_dir is guaranteed by early validation | ||
| 150 | let dir = git_data_dir.clone().expect("git_data_dir validated earlier"); | ||
| 151 | |||
| 152 | println!("Running all tests...\n"); | 121 | println!("Running all tests...\n"); |
| 153 | let mut all_results = AuditResult::new("All GRASP-01 Tests"); | 122 | let mut all_results = AuditResult::new("All GRASP-01 Tests"); |
| 154 | 123 | ||
| @@ -174,17 +143,17 @@ async fn main() -> Result<()> { | |||
| 174 | 143 | ||
| 175 | // Git clone tests | 144 | // Git clone tests |
| 176 | println!(" → Git clone tests..."); | 145 | println!(" → Git clone tests..."); |
| 177 | let clone_results = specs::GitCloneTests::run_all(&client, &dir, &relay_domain).await; | 146 | let clone_results = specs::GitCloneTests::run_all(&client, &relay_domain).await; |
| 178 | all_results.merge(clone_results); | 147 | all_results.merge(clone_results); |
| 179 | 148 | ||
| 180 | // Push authorization tests | 149 | // Push authorization tests |
| 181 | println!(" → Push authorization tests..."); | 150 | println!(" → Push authorization tests..."); |
| 182 | let push_results = specs::PushAuthorizationTests::run_all(&client, &dir, &relay_domain).await; | 151 | let push_results = specs::PushAuthorizationTests::run_all(&client, &relay_domain).await; |
| 183 | all_results.merge(push_results); | 152 | all_results.merge(push_results); |
| 184 | 153 | ||
| 185 | // Repository creation tests | 154 | // Repository creation tests |
| 186 | println!(" → Repository creation tests..."); | 155 | println!(" → Repository creation tests..."); |
| 187 | let repo_results = specs::RepositoryCreationTests::run_all(&client, &dir).await; | 156 | let repo_results = specs::RepositoryCreationTests::run_all(&client, &relay_domain).await; |
| 188 | all_results.merge(repo_results); | 157 | all_results.merge(repo_results); |
| 189 | 158 | ||
| 190 | println!(); | 159 | println!(); |