mirror of
https://relay.ngit.dev/npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/ngit-grasp.git
synced 2026-10-05 15:08:24 +00:00
Add MVP implementation for testing git HTTP protocol compliance: - Add git module with GitClient wrapper for HTTP protocol testing - Add GitHttpProtocolTests with test_gzip_encoded_upload_pack test - Add integration test in ngit-grasp that uses TestRelay fixture The test validates that the server correctly handles gzip-encoded git-upload-pack requests, which was the source of a production bug. Uses actual git fetch operations to test the real production scenario.
68 lines
2.1 KiB
Rust
68 lines
2.1 KiB
Rust
//! Git HTTP Protocol Integration Tests
|
|
//!
|
|
//! Tests that verify Git HTTP protocol compliance, particularly around
|
|
//! request encoding (gzip) and content negotiation.
|
|
//!
|
|
//! # Test Strategy
|
|
//!
|
|
//! - Each test runs in complete isolation with its own fresh relay instance
|
|
//! - Uses macro to eliminate boilerplate while maintaining test isolation
|
|
//! - Calls individual test methods from grasp-audit for minimal duplication
|
|
//! - Automatic cleanup via TestRelay fixture (removes container and temp dirs)
|
|
//!
|
|
//! # Background
|
|
//!
|
|
//! These tests validate the fix for a production bug where the server failed
|
|
//! to properly decompress gzip-encoded request bodies, causing git fetch/clone
|
|
//! operations to fail.
|
|
//!
|
|
//! # Running Tests
|
|
//!
|
|
//! ```bash
|
|
//! # Run all git HTTP protocol tests
|
|
//! cargo test --test git_http_protocol
|
|
//!
|
|
//! # Run specific test
|
|
//! cargo test --test git_http_protocol test_gzip_encoded_upload_pack
|
|
//!
|
|
//! # With output
|
|
//! cargo test --test git_http_protocol -- --nocapture
|
|
//! ```
|
|
|
|
mod common;
|
|
|
|
use common::TestRelay;
|
|
use grasp_audit::specs::grasp01::GitHttpProtocolTests;
|
|
use grasp_audit::*;
|
|
|
|
/// Macro to generate isolated integration tests with relay domain
|
|
///
|
|
/// Each test runs with its own fresh relay instance to ensure complete isolation.
|
|
/// This eliminates issues with leftover repositories and ensures clean state.
|
|
macro_rules! isolated_test {
|
|
($test_name:ident) => {
|
|
#[tokio::test]
|
|
async fn $test_name() {
|
|
let relay = TestRelay::start().await;
|
|
let config = AuditConfig::isolated();
|
|
let client = AuditClient::new(relay.url(), config)
|
|
.await
|
|
.expect("Failed to create audit client");
|
|
|
|
let result = GitHttpProtocolTests::$test_name(&client, &relay.domain()).await;
|
|
|
|
relay.stop().await;
|
|
|
|
assert!(
|
|
result.passed,
|
|
"{} failed: {}",
|
|
stringify!($test_name),
|
|
result.error.as_deref().unwrap_or("unknown error")
|
|
);
|
|
}
|
|
};
|
|
}
|
|
|
|
// Generate isolated tests for all git HTTP protocol tests
|
|
isolated_test!(test_gzip_encoded_upload_pack);
|