proto/tests/dtpm-config_test.rs
Noor b5289f1f5b DTPM: upload files as stream and directory support (#2)
archive directory to upload
bincode serialize files to seal and save
zstd compression for tar archive
tests with fixtures

Reviewed-on: #2
Co-authored-by: Noor <noormohammedb@protonmail.com>
Co-committed-by: Noor <noormohammedb@protonmail.com>
2025-04-21 14:40:59 +00:00

47 lines
1.1 KiB
Rust

use detee_shared::sgx::types::dtpm::{compress_directory, decompress_directory, DtpmConfig};
use std::sync::LazyLock;
static TEMP_DIR: LazyLock<String> = LazyLock::new(|| {
tempfile::tempdir()
.unwrap()
.into_path()
.to_string_lossy()
.to_string()
});
#[test]
fn dtpm_config_dir_support_test() {
let file_path = "tests/fixtures/dtpm_config.yaml";
let unloaded_config = DtpmConfig::from_path(file_path).unwrap();
let loaded_config = unloaded_config.load_data().unwrap();
dbg!(&loaded_config);
}
#[test]
fn test_compression() {
let file_path = "./tests";
let compressed_buff = compress_directory(file_path).unwrap();
dbg!(&TEMP_DIR);
std::fs::write(
format!("{}/{}", *TEMP_DIR, "archive.tar.zst"),
&compressed_buff,
)
.unwrap();
}
#[test]
fn test_decompression_02() {
let file_path = "./tests";
let archive_buff = compress_directory(file_path).unwrap();
decompress_directory(&TEMP_DIR, archive_buff).unwrap();
let path = format!("{}/{}", *TEMP_DIR, "tests/fixtures/dtpm_config.yaml");
assert!(std::path::Path::new(&path).exists());
}