atlas_cli/cc_attestation/
mock.rs

1use serde::{Deserialize, Serialize};
2use serde_json::json;
3
4use tdx_workload_attestation::error::Result;
5use tdx_workload_attestation::provider::AttestationProvider;
6
7pub struct MockAttestationProvider {
8    platform: String,
9}
10
11#[derive(Serialize, Deserialize, Debug)]
12pub struct MockReport {
13    report_type: String,
14    platform: String,
15    timestamp: String,
16    status: String,
17    version: String,
18    message: String,
19}
20
21impl MockAttestationProvider {
22    pub fn new(platform: &str) -> Self {
23        Self {
24            platform: platform.to_string(),
25        }
26    }
27}
28
29impl AttestationProvider for MockAttestationProvider {
30    fn get_attestation_report(&self) -> Result<String> {
31        // Create a mock attestation report with platform info
32        let mock_report = json!({
33            "report_type": "mock_attestation",
34            "platform": self.platform,
35            "timestamp": chrono::Utc::now().to_rfc3339(),
36            "version": "1.0",
37            "status": "simulated",
38            "message": "This is a mock attestation report for non-Linux or unsupported platforms"
39        });
40
41        // Serialize to JSON string
42        Ok(serde_json::to_string_pretty(&mock_report).unwrap_or_else(|_| "{}".to_string()))
43    }
44
45    fn get_launch_measurement(&self) -> Result<[u8; 48]> {
46        Ok([0; 48])
47    }
48}