()
| 1240 | |
| 1241 | #[test] |
| 1242 | fn test_to_report_data_with_hash() { |
| 1243 | let content_type = QuoteContentType::AppData; |
| 1244 | let content = b"test content"; |
| 1245 | |
| 1246 | let report_data = content_type.to_report_data(content); |
| 1247 | assert_eq!( |
| 1248 | hex::encode(report_data), |
| 1249 | "7ea0b744ed5e9c0c83ff9f575668e1697652cd349f2027cdf26f918d4c53e8cd50b5ea9b449b4c3d50e20ae00ec29688d5a214e8daff8a10041f5d624dae8a01" |
| 1250 | ); |
| 1251 | |
| 1252 | // Test SHA-256 |
| 1253 | let result = content_type |
| 1254 | .to_report_data_with_hash(content, "sha256") |
| 1255 | .unwrap(); |
| 1256 | assert_eq!(result[32..], [0u8; 32]); // Check padding |
| 1257 | assert_ne!(result[..32], [0u8; 32]); // Check hash is non-zero |
| 1258 | |
| 1259 | // Test SHA-384 |
| 1260 | let result = content_type |
| 1261 | .to_report_data_with_hash(content, "sha384") |
| 1262 | .unwrap(); |
| 1263 | assert_eq!(result[48..], [0u8; 16]); // Check padding |
| 1264 | assert_ne!(result[..48], [0u8; 48]); // Check hash is non-zero |
| 1265 | |
| 1266 | // Test default |
| 1267 | let result = content_type.to_report_data_with_hash(content, "").unwrap(); |
| 1268 | assert_ne!(result, [0u8; 64]); // Should fill entire buffer |
| 1269 | |
| 1270 | // Test raw content |
| 1271 | let exact_content = [42u8; 64]; |
| 1272 | let result = content_type |
| 1273 | .to_report_data_with_hash(&exact_content, "raw") |
| 1274 | .unwrap(); |
| 1275 | assert_eq!(result, exact_content); |
| 1276 | |
| 1277 | // Test invalid raw content length |
| 1278 | let invalid_content = [42u8; 65]; |
| 1279 | assert!(content_type |
| 1280 | .to_report_data_with_hash(&invalid_content, "raw") |
| 1281 | .is_err()); |
| 1282 | |
| 1283 | // Test invalid hash algorithm |
| 1284 | assert!(content_type |
| 1285 | .to_report_data_with_hash(content, "invalid") |
| 1286 | .is_err()); |
| 1287 | } |
| 1288 | |
| 1289 | #[test] |
| 1290 | fn v1_roundtrip_preserves_payload_in_stack() { |
nothing calls this directly
no test coverage detected