upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tests/push_authorization.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-11-26 05:45:47 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-11-26 07:38:58 +0000
commit30411a938d072a59d68815c975735d40366ad874 (patch)
treef802d1bf9f9959105d2d18af81c528722fa7a675 /tests/push_authorization.rs
parenta005132ab806b7177d4eb3e3306914841704ffec (diff)
feat: push authorization from state event
Diffstat (limited to 'tests/push_authorization.rs')
-rw-r--r--tests/push_authorization.rs70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/push_authorization.rs b/tests/push_authorization.rs
new file mode 100644
index 0000000..9e2dc67
--- /dev/null
+++ b/tests/push_authorization.rs
@@ -0,0 +1,70 @@
1//! Push Authorization Integration Tests
2//!
3//! Tests that verify push authorization state events work correctly.
4//!
5//! # Test Strategy
6//!
7//! - Each test runs in complete isolation with its own fresh relay instance
8//! - Uses macro to eliminate boilerplate while maintaining test isolation
9//! - Calls individual test methods from grasp-audit for minimal duplication
10//! - Automatic cleanup via TestRelay fixture (removes container and temp dirs)
11//!
12//! # Running Tests
13//!
14//! ```bash
15//! # Run all push authorization tests
16//! cargo test --test push_authorization
17//!
18//! # Run specific test
19//! cargo test --test push_authorization test_push_authorized_by_owner_state
20//!
21//! # With output
22//! cargo test --test push_authorization -- --nocapture
23//! ```
24
25mod common;
26
27use common::TestRelay;
28use grasp_audit::specs::grasp01::PushAuthorizationTests;
29use grasp_audit::*;
30
31/// Macro to generate isolated integration tests for push authorization
32///
33/// Each test runs with its own fresh relay instance to ensure complete isolation.
34/// This eliminates issues with leftover repositories and ensures clean state.
35/// Push authorization tests require git_data_dir and relay_domain parameters.
36macro_rules! isolated_push_test {
37 ($test_name:ident) => {
38 #[tokio::test]
39 async fn $test_name() {
40 let relay = TestRelay::start().await;
41 let config = AuditConfig::ci();
42 let client = AuditClient::new(relay.url(), config)
43 .await
44 .expect("Failed to create audit client");
45
46 let result = PushAuthorizationTests::$test_name(
47 &client,
48 relay.git_data_dir(),
49 &relay.domain()
50 ).await;
51
52 relay.stop().await;
53
54 assert!(
55 result.passed,
56 "{} failed: {}",
57 stringify!($test_name),
58 result.error.as_deref().unwrap_or("unknown error")
59 );
60 }
61 };
62}
63
64// Generate isolated tests for all push authorization tests
65isolated_push_test!(test_push_authorized_by_owner_state);
66isolated_push_test!(test_push_rejected_without_state_event);
67isolated_push_test!(test_push_rejected_wrong_commit);
68isolated_push_test!(test_recursive_maintainer_authorization);
69isolated_push_test!(test_latest_state_event_used);
70isolated_push_test!(test_non_maintainer_state_rejected); \ No newline at end of file