Files
IronStorage/crates/storage/tests/android_private_context.rs
T
hugo 874c8139a4
Dependency security audit / rustsec (push) Failing after 23s
feat(android): implement private Rust storage runtime (#90)
2026-10-08 14:36:05 +02:00

59 lines
1.8 KiB
Rust

#![forbid(unsafe_code)]
use ironstorage::{
config::{Config, ConfigLoader},
mobile::{MobileShell, MobileShellState},
mobile_onboarding::MobileOnboardingOperation,
mobile_private_storage::{PrivateDirectories, PrivateStorage},
repository::SecretBytes,
};
use std::{error::Error, fs};
#[test]
fn activated_os_roots_drive_existing_local_setup_and_configuration_apis()
-> Result<(), Box<dyn Error>> {
let temp = tempfile::tempdir()?;
for name in ["files", "no-backup", "cache"] {
fs::create_dir(temp.path().join(name))?;
}
let storage = PrivateStorage::open(PrivateDirectories {
files: fs::canonicalize(temp.path().join("files"))?,
no_backup: fs::canonicalize(temp.path().join("no-backup"))?,
cache: fs::canonicalize(temp.path().join("cache"))?,
})?;
storage.activate()?;
assert_eq!(
ConfigLoader::system()?.default_path(),
storage.root().join("config.toml")
);
assert_eq!(
MobileShell::load().pages()[0].state(),
MobileShellState::Empty
);
MobileOnboardingOperation::default().setup_local_generated(
"Android private fixture <fixture@example.test>",
SecretBytes::new(b"public-test-passphrase".to_vec()),
false,
)?;
let config = Config::load(None)?;
assert!(storage.status().configured);
assert_eq!(config.vault(), storage.root().join("vault"));
assert_eq!(config.key_material(), storage.root().join("keys"));
assert_eq!(
MobileShell::load().pages()[0].state(),
MobileShellState::Ready
);
assert!(
config
.source()
.strip_prefix(temp.path().join("files"))
.is_err()
);
assert!(
config
.source()
.strip_prefix(temp.path().join("cache"))
.is_err()
);
Ok(())
}