fix: use client_path to test successful writing of snapshot file
@@ -396,13 +396,37 @@ fn test_load_client_from_non_existing_snapshot() {
#[test]
fn test_create_snapshot_file_in_custom_directory() {
let client_path = "my-awesome-client-path";
+ let vault_path = b"vault_path".to_vec();
+ let record_path = b"record_path".to_vec();
+ let payload = b"payload".to_vec();
+ let location = Location::const_generic(vault_path.clone(), record_path.clone());
let stronghold = Stronghold::default();
let mut temp_dir = std::env::temp_dir();
temp_dir = temp_dir.join("idkfa.snapshot");
- let snapshot_path = SnapshotPath::from_path(format!("{:?}", temp_dir.as_path()));
+ let snapshot_path = SnapshotPath::from_path(temp_dir.as_path());
let password = rand::fixed_bytestring(32);
let keyprovider = KeyProvider::try_from(password).expect("KeyProvider failed");
+ let result = stronghold.create_client(client_path);
+ assert!(result.is_ok());
+
+ let client = result.unwrap();
+ let vault = client.vault(vault_path.clone());
+
+ assert!(vault.write_secret(location, payload.clone()).is_ok());
+
assert!(stronghold.commit(&snapshot_path, &keyprovider).is_ok());
+
+ let client2 = stronghold.load_client_from_snapshot(client_path, &keyprovider, &snapshot_path);
+ assert!(client2.is_ok());
+
+ let client2 = client2.unwrap();
+
+ let vault2 = client2.vault(vault_path);
+ let secret = vault2.read_secret(record_path);
+ assert!(secret.is_ok());
+
+ let secret = secret.unwrap();
+ assert!(secret.eq(&payload));
}
