From f053827e0a157f348d9cf834f026a8de322abfe2 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 28 Nov 2025 01:44:58 +0000 Subject: grasp-audit run all tests in audit mode --- grasp-audit/src/specs/grasp01/git_clone.rs | 14 ++++++++++++++ grasp-audit/src/specs/grasp01/mod.rs | 14 +++++++++++++- grasp-audit/src/specs/grasp01/push_authorization.rs | 16 ++++++++++++++++ grasp-audit/src/specs/grasp01/repository_creation.rs | 14 ++++++++++++++ grasp-audit/src/specs/mod.rs | 7 ++++++- 5 files changed, 63 insertions(+), 2 deletions(-) (limited to 'grasp-audit/src/specs') diff --git a/grasp-audit/src/specs/grasp01/git_clone.rs b/grasp-audit/src/specs/grasp01/git_clone.rs index da60f26..8c91c04 100644 --- a/grasp-audit/src/specs/grasp01/git_clone.rs +++ b/grasp-audit/src/specs/grasp01/git_clone.rs @@ -24,6 +24,20 @@ use std::process::Command; pub struct GitCloneTests; impl GitCloneTests { + /// Run all Git clone tests + pub async fn run_all( + client: &AuditClient, + git_data_dir: &Path, + relay_domain: &str, + ) -> crate::AuditResult { + let mut results = crate::AuditResult::new("GRASP-01 Git Clone Tests"); + + results.add(Self::test_basic_git_clone(client, git_data_dir, relay_domain).await); + results.add(Self::test_clone_url_format(client, git_data_dir, relay_domain).await); + + results + } + /// Test that a repository can be cloned via Git HTTP backend /// /// This test: diff --git a/grasp-audit/src/specs/grasp01/mod.rs b/grasp-audit/src/specs/grasp01/mod.rs index 0d0bd9c..b5471d1 100644 --- a/grasp-audit/src/specs/grasp01/mod.rs +++ b/grasp-audit/src/specs/grasp01/mod.rs @@ -1,4 +1,16 @@ //! GRASP-01 specification tests +//! +//! This module contains all test suites for GRASP-01 compliance testing. +//! +//! ## Test Suites +//! +//! - [`Nip01SmokeTests`] - Basic NIP-01 relay functionality (WebSocket-only) +//! - [`Nip11DocumentTests`] - NIP-11 relay information document (WebSocket-only) +//! - [`EventAcceptancePolicyTests`] - Event acceptance rules (WebSocket-only) +//! - [`CorsTests`] - CORS headers on Git HTTP endpoints (requires git-data-dir) +//! - [`GitCloneTests`] - Git clone operations (requires git-data-dir) +//! - [`PushAuthorizationTests`] - Push authorization (requires git-data-dir) +//! - [`RepositoryCreationTests`] - Repository creation (requires git-data-dir) pub mod cors; pub mod event_acceptance_policy; @@ -14,4 +26,4 @@ pub use git_clone::GitCloneTests; pub use nip01_smoke::Nip01SmokeTests; pub use nip11_document::Nip11DocumentTests; pub use push_authorization::PushAuthorizationTests; -pub use repository_creation::RepositoryCreationTests; +pub use repository_creation::{is_bare_repository, RepositoryCreationTests}; diff --git a/grasp-audit/src/specs/grasp01/push_authorization.rs b/grasp-audit/src/specs/grasp01/push_authorization.rs index fad77fb..4599ea5 100644 --- a/grasp-audit/src/specs/grasp01/push_authorization.rs +++ b/grasp-audit/src/specs/grasp01/push_authorization.rs @@ -30,6 +30,22 @@ use std::path::Path; pub struct PushAuthorizationTests; impl PushAuthorizationTests { + /// Run all push authorization tests + pub async fn run_all( + client: &AuditClient, + git_data_dir: &Path, + relay_domain: &str, + ) -> crate::AuditResult { + let mut results = crate::AuditResult::new("GRASP-01 Push Authorization Tests"); + + results.add(Self::test_push_authorized_by_owner_state(client, git_data_dir, relay_domain).await); + results.add(Self::test_push_rejected_without_state_event(client, git_data_dir, relay_domain).await); + results.add(Self::test_push_rejected_wrong_commit(client, git_data_dir, relay_domain).await); + results.add(Self::test_push_authorized_by_maintainer_state_only(client, git_data_dir, relay_domain).await); + + results + } + /// Test that push is authorized when state event matches the commit /// /// GRASP-01: "MUST accept pushes via this service that match the latest diff --git a/grasp-audit/src/specs/grasp01/repository_creation.rs b/grasp-audit/src/specs/grasp01/repository_creation.rs index 31ef400..2eaf32f 100644 --- a/grasp-audit/src/specs/grasp01/repository_creation.rs +++ b/grasp-audit/src/specs/grasp01/repository_creation.rs @@ -24,6 +24,20 @@ use std::path::Path; pub struct RepositoryCreationTests; impl RepositoryCreationTests { + /// Run all repository creation tests + pub async fn run_all( + client: &AuditClient, + git_data_dir: &Path, + ) -> crate::AuditResult { + let mut results = crate::AuditResult::new("GRASP-01 Repository Creation Tests"); + + results.add(Self::test_bare_repo_created_on_announcement(client, git_data_dir).await); + results.add(Self::test_repo_creation_idempotent(client, git_data_dir).await); + results.add(Self::test_bare_repo_structure(client, git_data_dir).await); + + results + } + /// Test that a bare repository is created when a valid announcement is accepted /// /// This test: diff --git a/grasp-audit/src/specs/mod.rs b/grasp-audit/src/specs/mod.rs index a502866..1444c80 100644 --- a/grasp-audit/src/specs/mod.rs +++ b/grasp-audit/src/specs/mod.rs @@ -1,6 +1,11 @@ //! Test specifications +//! +//! This module contains all GRASP specification test suites. pub mod grasp01; // Re-export all test structs from grasp01 module -pub use grasp01::{EventAcceptancePolicyTests, Nip01SmokeTests, Nip11DocumentTests}; +pub use grasp01::{ + CorsTests, EventAcceptancePolicyTests, GitCloneTests, Nip01SmokeTests, Nip11DocumentTests, + PushAuthorizationTests, RepositoryCreationTests, +}; -- cgit v1.2.3