reinhardt-utils 0.1.0-rc.22

Utility functions aggregator for Reinhardt
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
//! Local filesystem storage backend

use super::backend::Storage;
use super::errors::{StorageError, StorageResult};
use super::file::{FileMetadata, StoredFile};
use async_trait::async_trait;
use sha2::{Digest, Sha256};
use std::path::{Path, PathBuf};
use tokio::fs;

/// Local filesystem storage
pub struct LocalStorage {
	base_path: PathBuf,
	base_url: String,
}

impl LocalStorage {
	/// Create a new local filesystem storage backend
	///
	/// # Examples
	///
	/// ```
	/// use reinhardt_utils::storage::{LocalStorage, Storage};
	///
	/// let storage = LocalStorage::new("/tmp/storage", "http://localhost/media");
	/// assert_eq!(storage.url("test.txt"), "http://localhost/media/test.txt");
	/// ```
	pub fn new(base_path: impl Into<PathBuf>, base_url: impl Into<String>) -> Self {
		Self {
			base_path: base_path.into(),
			base_url: base_url.into(),
		}
	}
	/// Ensure the base directory exists, creating it if necessary
	///
	/// # Examples
	///
	/// ```
	/// use reinhardt_utils::storage::LocalStorage;
	/// use tempfile::TempDir;
	///
	/// # tokio_test::block_on(async {
	/// let temp_dir = TempDir::new().unwrap();
	/// let storage_path = temp_dir.path().join("new_storage");
	/// let storage = LocalStorage::new(&storage_path, "http://localhost/media");
	///
	/// storage.ensure_base_dir().await.unwrap();
	/// assert!(storage_path.exists());
	/// # });
	/// ```
	pub async fn ensure_base_dir(&self) -> StorageResult<()> {
		fs::create_dir_all(&self.base_path).await?;
		Ok(())
	}

	fn full_path(&self, path: &str) -> PathBuf {
		self.base_path.join(path)
	}

	/// Validate path to prevent directory traversal attacks
	fn validate_path(path: &str) -> StorageResult<()> {
		// Check for absolute paths
		if path.starts_with('/') || path.starts_with('\\') {
			return Err(StorageError::InvalidPath(format!(
				"Detected path traversal attempt in '{}'",
				path
			)));
		}

		// Check for parent directory references
		let path_obj = Path::new(path);
		for component in path_obj.components() {
			if component == std::path::Component::ParentDir {
				return Err(StorageError::InvalidPath(format!(
					"Detected path traversal attempt in '{}'",
					path
				)));
			}
		}

		// Check if path is just current dir or empty
		if path == "." || path == ".." || path.is_empty() {
			return Err(StorageError::InvalidPath(format!(
				"Could not derive file name from '{}'",
				path
			)));
		}

		Ok(())
	}

	fn compute_checksum(content: &[u8]) -> String {
		let mut hasher = Sha256::new();
		hasher.update(content);
		hex::encode(hasher.finalize())
	}
}

#[async_trait]
impl Storage for LocalStorage {
	async fn save(&self, path: &str, content: &[u8]) -> StorageResult<FileMetadata> {
		// Validate path to prevent directory traversal
		Self::validate_path(path)?;

		let full_path = self.full_path(path);

		// Create parent directories if needed
		if let Some(parent) = full_path.parent() {
			fs::create_dir_all(parent).await?;
		}

		// Write file
		fs::write(&full_path, content).await?;

		// Get file metadata
		let file_meta = fs::metadata(&full_path).await?;
		let size = file_meta.len();
		let checksum = Self::compute_checksum(content);

		Ok(FileMetadata::new(path.to_string(), size).with_checksum(checksum))
	}

	async fn read(&self, path: &str) -> StorageResult<StoredFile> {
		// Validate path to prevent directory traversal
		Self::validate_path(path)?;

		let full_path = self.full_path(path);

		if !full_path.exists() {
			return Err(StorageError::NotFound(path.to_string()));
		}

		let content = fs::read(&full_path).await?;
		let file_meta = fs::metadata(&full_path).await?;
		let size = file_meta.len();

		let metadata = FileMetadata::new(path.to_string(), size);
		Ok(StoredFile::new(metadata, content))
	}

	async fn delete(&self, path: &str) -> StorageResult<()> {
		// Validate path to prevent directory traversal
		Self::validate_path(path)?;

		let full_path = self.full_path(path);

		if !full_path.exists() {
			return Err(StorageError::NotFound(path.to_string()));
		}

		fs::remove_file(&full_path).await?;
		Ok(())
	}

	async fn exists(&self, path: &str) -> StorageResult<bool> {
		// Validate path to prevent directory traversal
		Self::validate_path(path)?;

		let full_path = self.full_path(path);
		Ok(full_path.exists())
	}

	async fn metadata(&self, path: &str) -> StorageResult<FileMetadata> {
		// Validate path to prevent directory traversal
		Self::validate_path(path)?;

		let full_path = self.full_path(path);

		if !full_path.exists() {
			return Err(StorageError::NotFound(path.to_string()));
		}

		let file_meta = fs::metadata(&full_path).await?;
		let size = file_meta.len();

		Ok(FileMetadata::new(path.to_string(), size))
	}

	async fn list(&self, path: &str) -> StorageResult<Vec<FileMetadata>> {
		// Validate path to prevent directory traversal
		// Empty path is allowed to list the base directory
		if !path.is_empty() {
			Self::validate_path(path)?;
		}

		let full_path = self.full_path(path);
		let mut entries = fs::read_dir(&full_path).await?;
		let mut results = Vec::new();

		while let Some(entry) = entries.next_entry().await? {
			let metadata = entry.metadata().await?;
			if metadata.is_file() {
				let file_name = entry.file_name().to_string_lossy().to_string();
				let relative_path = Path::new(path).join(&file_name);
				results.push(FileMetadata::new(
					relative_path.to_string_lossy().to_string(),
					metadata.len(),
				));
			}
		}

		Ok(results)
	}

	fn url(&self, path: &str) -> String {
		format!(
			"{}/{}",
			self.base_url.trim_end_matches('/'),
			path.trim_start_matches('/')
		)
	}

	fn path(&self, name: &str) -> String {
		name.to_string()
	}

	async fn get_accessed_time(&self, path: &str) -> StorageResult<chrono::DateTime<chrono::Utc>> {
		// Validate path to prevent directory traversal
		Self::validate_path(path)?;

		let full_path = self.full_path(path);

		if !full_path.exists() {
			return Err(StorageError::NotFound(path.to_string()));
		}

		let file_meta = fs::metadata(&full_path).await?;
		let accessed = file_meta.accessed()?;
		let datetime: chrono::DateTime<chrono::Utc> = accessed.into();
		Ok(datetime)
	}

	async fn get_created_time(&self, path: &str) -> StorageResult<chrono::DateTime<chrono::Utc>> {
		// Validate path to prevent directory traversal
		Self::validate_path(path)?;

		let full_path = self.full_path(path);

		if !full_path.exists() {
			return Err(StorageError::NotFound(path.to_string()));
		}

		let file_meta = fs::metadata(&full_path).await?;
		let created = file_meta.created()?;
		let datetime: chrono::DateTime<chrono::Utc> = created.into();
		Ok(datetime)
	}

	async fn get_modified_time(&self, path: &str) -> StorageResult<chrono::DateTime<chrono::Utc>> {
		// Validate path to prevent directory traversal
		Self::validate_path(path)?;

		let full_path = self.full_path(path);

		if !full_path.exists() {
			return Err(StorageError::NotFound(path.to_string()));
		}

		let file_meta = fs::metadata(&full_path).await?;
		let modified = file_meta.modified()?;
		let datetime: chrono::DateTime<chrono::Utc> = modified.into();
		Ok(datetime)
	}
}

#[cfg(test)]
mod tests {
	use super::*;
	use tempfile::TempDir;

	async fn create_test_storage() -> (LocalStorage, TempDir) {
		let temp_dir = TempDir::new().unwrap();
		let storage = LocalStorage::new(temp_dir.path(), "http://localhost/media");
		storage.ensure_base_dir().await.unwrap();
		(storage, temp_dir)
	}

	#[tokio::test]
	async fn test_local_storage_path() {
		let storage = LocalStorage::new("/tmp/storage", "http://localhost/media");
		assert_eq!(storage.url("test.txt"), "http://localhost/media/test.txt");
	}

	#[tokio::test]
	async fn test_file_access_options() {
		let (storage, _temp_dir) = create_test_storage().await;

		// Test that file doesn't exist initially
		assert!(!storage.exists("storage_test").await.unwrap());

		// Save a file
		let content = b"storage contents";
		storage.save("storage_test", content).await.unwrap();

		// Check file exists
		assert!(storage.exists("storage_test").await.unwrap());

		// Read file content
		let file = storage.read("storage_test").await.unwrap();
		assert_eq!(file.content, content);

		// Delete file
		storage.delete("storage_test").await.unwrap();
		assert!(!storage.exists("storage_test").await.unwrap());
	}

	#[tokio::test]
	async fn test_file_save_with_path() {
		let (storage, _temp_dir) = create_test_storage().await;

		// Saving a pathname should create intermediate directories
		assert!(!storage.exists("path/to").await.unwrap());

		storage
			.save("path/to/test.file", b"file saved with path")
			.await
			.unwrap();

		assert!(storage.exists("path/to/test.file").await.unwrap());

		let file = storage.read("path/to/test.file").await.unwrap();
		assert_eq!(file.content, b"file saved with path");

		storage.delete("path/to/test.file").await.unwrap();
	}

	#[tokio::test]
	async fn test_file_size() {
		let (storage, _temp_dir) = create_test_storage().await;

		storage.save("file.txt", b"test").await.unwrap();
		let metadata = storage.metadata("file.txt").await.unwrap();
		assert_eq!(metadata.size, 4);

		storage.delete("file.txt").await.unwrap();
	}

	#[tokio::test]
	async fn test_exists() {
		let (storage, _temp_dir) = create_test_storage().await;

		storage.save("dir/subdir/file.txt", b"test").await.unwrap();
		assert!(storage.exists("dir/subdir/file.txt").await.unwrap());

		storage.delete("dir/subdir/file.txt").await.unwrap();
	}

	#[tokio::test]
	async fn test_delete() {
		let (storage, _temp_dir) = create_test_storage().await;

		storage.save("dir/subdir/file.txt", b"test").await.unwrap();
		storage
			.save("dir/subdir/other_file.txt", b"test")
			.await
			.unwrap();

		assert!(storage.exists("dir/subdir/file.txt").await.unwrap());
		assert!(storage.exists("dir/subdir/other_file.txt").await.unwrap());

		storage.delete("dir/subdir/other_file.txt").await.unwrap();
		assert!(!storage.exists("dir/subdir/other_file.txt").await.unwrap());

		storage.delete("dir/subdir/file.txt").await.unwrap();
		assert!(!storage.exists("dir/subdir/file.txt").await.unwrap());
	}

	#[tokio::test]
	async fn test_delete_missing_file() {
		let (storage, _temp_dir) = create_test_storage().await;

		// Deleting a missing file should return an error
		let result = storage.delete("missing_file.txt").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::NotFound(_)));
	}

	#[tokio::test]
	async fn test_file_url() {
		let storage = LocalStorage::new("/tmp/storage", "http://localhost/media");

		assert_eq!(storage.url("test.file"), "http://localhost/media/test.file");

		// Test URL with base_url without trailing slash
		let storage2 = LocalStorage::new("/tmp/storage", "http://localhost/media/");
		assert_eq!(
			storage2.url("test.file"),
			"http://localhost/media/test.file"
		);
	}

	#[tokio::test]
	async fn test_base_url() {
		// Test with no trailing slash in base_url
		let storage = LocalStorage::new("/tmp/storage", "http://localhost/no_ending_slash");
		assert_eq!(
			storage.url("test.file"),
			"http://localhost/no_ending_slash/test.file"
		);
	}

	#[tokio::test]
	async fn test_listdir() {
		let (storage, _temp_dir) = create_test_storage().await;

		storage
			.save("storage_test_1", b"custom content")
			.await
			.unwrap();
		storage
			.save("storage_test_2", b"custom content")
			.await
			.unwrap();
		storage.save("dir/file_c.txt", b"test").await.unwrap();

		let files = storage.list("").await.unwrap();
		let file_names: Vec<String> = files
			.iter()
			.map(|f| {
				std::path::Path::new(&f.path)
					.file_name()
					.unwrap()
					.to_string_lossy()
					.to_string()
			})
			.collect();

		assert!(file_names.contains(&"storage_test_1".to_string()));
		assert!(file_names.contains(&"storage_test_2".to_string()));

		// Cleanup
		storage.delete("storage_test_1").await.unwrap();
		storage.delete("storage_test_2").await.unwrap();
		storage.delete("dir/file_c.txt").await.unwrap();
	}

	#[tokio::test]
	async fn test_open_missing_file() {
		let (storage, _temp_dir) = create_test_storage().await;

		let result = storage.read("missing.txt").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::NotFound(_)));
	}

	#[tokio::test]
	async fn test_large_file_saving() {
		let (storage, _temp_dir) = create_test_storage().await;

		// Create a large file (3 * 64KB)
		let large_content = vec![b'A'; 64 * 1024 * 3];
		storage
			.save("large_file.txt", &large_content)
			.await
			.unwrap();

		let metadata = storage.metadata("large_file.txt").await.unwrap();
		assert_eq!(metadata.size, large_content.len() as u64);

		storage.delete("large_file.txt").await.unwrap();
	}

	#[tokio::test]
	async fn test_file_checksum() {
		let (storage, _temp_dir) = create_test_storage().await;

		let metadata = storage.save("file.txt", b"test").await.unwrap();
		assert!(metadata.checksum.is_some());

		// Same content should produce same checksum
		let metadata2 = storage.save("file2.txt", b"test").await.unwrap();
		assert_eq!(metadata.checksum, metadata2.checksum);

		storage.delete("file.txt").await.unwrap();
		storage.delete("file2.txt").await.unwrap();
	}

	#[tokio::test]
	async fn test_file_get_accessed_time() {
		let (storage, _temp_dir) = create_test_storage().await;

		storage.save("test.file", b"custom contents").await.unwrap();

		let atime = storage.get_accessed_time("test.file").await.unwrap();
		let now = chrono::Utc::now();

		// Access time should be close to current time
		let diff = (now - atime).num_seconds().abs();
		assert!(
			diff < 5,
			"Access time difference too large: {} seconds",
			diff
		);

		storage.delete("test.file").await.unwrap();
	}

	#[tokio::test]
	async fn test_file_get_created_time() {
		let (storage, _temp_dir) = create_test_storage().await;

		storage.save("test.file", b"custom contents").await.unwrap();

		let ctime = storage.get_created_time("test.file").await.unwrap();
		let now = chrono::Utc::now();

		// Creation time should be close to current time
		let diff = (now - ctime).num_seconds().abs();
		assert!(
			diff < 5,
			"Creation time difference too large: {} seconds",
			diff
		);

		storage.delete("test.file").await.unwrap();
	}

	#[tokio::test]
	async fn test_file_get_modified_time() {
		let (storage, _temp_dir) = create_test_storage().await;

		storage.save("test.file", b"custom contents").await.unwrap();

		let mtime = storage.get_modified_time("test.file").await.unwrap();
		let now = chrono::Utc::now();

		// Modified time should be close to current time
		let diff = (now - mtime).num_seconds().abs();
		assert!(
			diff < 5,
			"Modified time difference too large: {} seconds",
			diff
		);

		storage.delete("test.file").await.unwrap();
	}

	#[tokio::test]
	async fn test_file_modified_time_changes() {
		use tokio::time::{Duration, sleep};

		let (storage, _temp_dir) = create_test_storage().await;

		storage.save("file.txt", b"test").await.unwrap();
		let modified_time = storage.get_modified_time("file.txt").await.unwrap();

		// Wait a bit
		sleep(Duration::from_millis(100)).await;

		// Modify the file
		storage.save("file.txt", b"new content").await.unwrap();

		let new_modified_time = storage.get_modified_time("file.txt").await.unwrap();
		assert!(
			new_modified_time > modified_time,
			"Modified time should increase after file change"
		);

		storage.delete("file.txt").await.unwrap();
	}

	#[tokio::test]
	async fn test_file_storage_prevents_directory_traversal() {
		let (storage, _temp_dir) = create_test_storage().await;

		// Test parent directory traversal
		let result = storage.save("../test.txt", b"test").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));

		// Test absolute path
		let result = storage.save("/etc/passwd", b"test").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));
	}

	#[tokio::test]
	async fn test_storage_dangerous_paths() {
		let (storage, _temp_dir) = create_test_storage().await;

		let dangerous_paths = vec!["..", ".", "", "../path", "tmp/../path", "/tmp/path"];

		for path in dangerous_paths {
			let result = storage.save(path, b"test").await;
			assert!(
				result.is_err(),
				"Path '{}' should be rejected but was accepted",
				path
			);
			assert!(
				matches!(result.unwrap_err(), StorageError::InvalidPath(_)),
				"Path '{}' should return InvalidPath error",
				path
			);
		}
	}

	#[tokio::test]
	async fn test_path_with_dots_in_filename() {
		let (storage, _temp_dir) = create_test_storage().await;

		// Valid path with dots in directory and filename should work
		storage.save("my.dir/test.file.txt", b"test").await.unwrap();
		assert!(storage.exists("my.dir/test.file.txt").await.unwrap());

		storage.delete("my.dir/test.file.txt").await.unwrap();
	}

	#[tokio::test]
	async fn test_url_encoding() {
		let storage = LocalStorage::new("/tmp/storage", "http://localhost/media");

		// Basic file
		assert_eq!(storage.url("test.file"), "http://localhost/media/test.file");

		// File with special characters (note: basic implementation doesn't encode)
		// This test documents current behavior
		let url = storage.url("test file.txt");
		assert!(url.contains("test file.txt"));
	}

	#[tokio::test]
	async fn test_read_prevents_directory_traversal() {
		let (storage, _temp_dir) = create_test_storage().await;

		// Test parent directory traversal
		let result = storage.read("../test.txt").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));

		// Test absolute path
		let result = storage.read("/etc/passwd").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));

		// Test embedded parent directory
		let result = storage.read("tmp/../test.txt").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));
	}

	#[tokio::test]
	async fn test_delete_prevents_directory_traversal() {
		let (storage, _temp_dir) = create_test_storage().await;

		// Test parent directory traversal
		let result = storage.delete("../test.txt").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));

		// Test absolute path
		let result = storage.delete("/etc/passwd").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));
	}

	#[tokio::test]
	async fn test_exists_prevents_directory_traversal() {
		let (storage, _temp_dir) = create_test_storage().await;

		// Test parent directory traversal
		let result = storage.exists("../test.txt").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));

		// Test absolute path
		let result = storage.exists("/etc/passwd").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));
	}

	#[tokio::test]
	async fn test_metadata_prevents_directory_traversal() {
		let (storage, _temp_dir) = create_test_storage().await;

		// Test parent directory traversal
		let result = storage.metadata("../test.txt").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));

		// Test absolute path
		let result = storage.metadata("/etc/passwd").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));
	}

	#[tokio::test]
	async fn test_list_prevents_directory_traversal() {
		let (storage, _temp_dir) = create_test_storage().await;

		// Test parent directory traversal
		let result = storage.list("../test").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));

		// Test absolute path
		let result = storage.list("/etc").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));
	}

	#[tokio::test]
	async fn test_get_time_operations_prevent_directory_traversal() {
		let (storage, _temp_dir) = create_test_storage().await;

		// Test get_accessed_time
		let result = storage.get_accessed_time("../test.txt").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));

		// Test get_created_time
		let result = storage.get_created_time("../test.txt").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));

		// Test get_modified_time
		let result = storage.get_modified_time("../test.txt").await;
		assert!(result.is_err());
		assert!(matches!(result.unwrap_err(), StorageError::InvalidPath(_)));
	}
}