feat(android): implement private Rust storage runtime (#90)
Dependency security audit / rustsec (push) Failing after 23s
Dependency security audit / rustsec (push) Failing after 23s
This commit is contained in:
1 parent
180851087b
commit
874c8139a4
36 files changed
+2848
-39
No files matched your search
@@ -0,0 +1,58 @@
|
||||
#![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(())
|
||||
}
|
||||
Reference in new issue
Block a user