upleb.uk

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

summaryrefslogtreecommitdiff
path: root/grasp-audit/src/fixtures.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 /grasp-audit/src/fixtures.rs
parenta005132ab806b7177d4eb3e3306914841704ffec (diff)
feat: push authorization from state event
Diffstat (limited to 'grasp-audit/src/fixtures.rs')
-rw-r--r--grasp-audit/src/fixtures.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/grasp-audit/src/fixtures.rs b/grasp-audit/src/fixtures.rs
index 8eee81f..4b30cb6 100644
--- a/grasp-audit/src/fixtures.rs
+++ b/grasp-audit/src/fixtures.rs
@@ -28,6 +28,17 @@ use nostr_sdk::prelude::Event;
28use std::collections::HashMap; 28use std::collections::HashMap;
29use std::sync::{Arc, Mutex}; 29use std::sync::{Arc, Mutex};
30 30
31/// Deterministic commit hash used in RepoState fixtures
32/// This is the hash produced by creating a commit with:
33/// - Message: "Initial commit"
34/// - File: test.txt containing "Initial commit"
35/// - Author date: 2024-01-01T00:00:00Z
36/// - Committer date: 2024-01-01T00:00:00Z
37/// - GPG signing: disabled
38/// - User: "GRASP Audit Test <test@grasp-audit.local>"
39/// - Parent: Initial empty commit (09cc37de80f3434fa98864a86730b8d7777bd6ae)
40pub const DETERMINISTIC_COMMIT_HASH: &str = "64ea71d79a57a7acb334cd9651f8aec067c0ce5d";
41
31/// Types of test fixtures available 42/// Types of test fixtures available
32#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 43#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
33pub enum FixtureKind { 44pub enum FixtureKind {
@@ -279,17 +290,18 @@ impl<'a> TestContext<'a> {
279 .ok_or_else(|| anyhow::anyhow!("Missing d tag in repo announcement"))? 290 .ok_or_else(|| anyhow::anyhow!("Missing d tag in repo announcement"))?
280 .to_string(); 291 .to_string();
281 292
282 // Create state announcement 293 // Create state announcement with deterministic commit hash
294 // Tag format: ["refs/heads/main", "<commit_hash>"]
283 self.client 295 self.client
284 .event_builder(Kind::Custom(30618), "") 296 .event_builder(Kind::Custom(30618), "")
285 .tag(Tag::identifier(&repo_id)) 297 .tag(Tag::identifier(&repo_id))
286 .tag(Tag::custom( 298 .tag(Tag::custom(
287 TagKind::custom("refs/heads/main"), 299 TagKind::custom("refs/heads/main"),
288 vec!["abc123def456789012345678901234567890abcd"], 300 vec![DETERMINISTIC_COMMIT_HASH.to_string()],
289 )) 301 ))
290 .tag(Tag::custom( 302 .tag(Tag::custom(
291 TagKind::custom("HEAD"), 303 TagKind::custom("HEAD"),
292 vec!["ref: refs/heads/main"], 304 vec!["ref: refs/heads/main".to_string()],
293 )) 305 ))
294 .build(self.client.keys()) 306 .build(self.client.keys())
295 .map_err(|e| anyhow::anyhow!("Failed to build state announcement: {}", e)) 307 .map_err(|e| anyhow::anyhow!("Failed to build state announcement: {}", e))