#![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> { 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 ", 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(()) }