Share the platform-neutral Rust mobile contract (#91)
Dependency security audit / rustsec (push) Failing after 22s

This commit is contained in:
hugo committed 2026-10-08 13:25:09 +02:00
1 parent fcb36a0684
commit 180851087b
52 files changed
+8932 -4263

No files matched your search

@@ -26,6 +26,74 @@ use support::compatibility::FixtureSet;
type TestResult<T = ()> = Result<T, Box<dyn Error>>;
#[test]
fn mobile_context_uses_injected_os_backend_clock_and_lifecycle_without_global_configuration()
-> TestResult {
use ironstorage::{
config::Config, mobile_authentication::MobileAuthentication,
mobile_platform::MobileLifecycleEvent,
};
let fixture = FixtureSet::load()?;
let vault = fixture.materialize_store("basic")?;
let root = tempfile::tempdir()?;
let source = root.path().join("config.toml");
std::fs::write(
&source,
format!(
"vault = {:?}\nkey_material = {:?}\ndefault_key = {:?}\n[[git.remotes]]\nname = \"origin\"\nurl = \"https://example.test/team/passwords.git\"\nserver_id = \"server-example\"\napplication_id = \"repository-example\"\n",
vault.path().to_str().expect("fixture UTF8"),
fixture.path("keys").to_str().expect("fixture UTF8"),
fixture.key("alice")?.primary_fingerprint,
),
)?;
let backend = MemoryBackend::default();
let clock = ManualClock::default();
let authentication = MobileAuthentication::with_platform(
Config::load(Some(&source))?,
Arc::new(backend.clone()),
Arc::new(clock.clone()),
)?;
assert!(
!authentication
.lifecycle(MobileLifecycleEvent::Foreground)?
.unlocked()
);
assert_eq!(
authentication
.preferences(false, false, false)?
.application_account(),
None
);
assert_eq!(
backend.retrieves(),
1,
"preferences must use the injected backend"
);
authentication.set_authentication_timeout(30)?;
authentication.unlock_entry(
"email/personal",
Some(SecretBytes::new(
fixture.key("alice")?.passphrase.as_bytes().to_vec(),
)),
)?;
assert!(authentication.state()?.unlocked());
clock.advance(Duration::from_secs(20));
assert_eq!(authentication.state()?.remaining_seconds(), 10);
authentication.lifecycle(MobileLifecycleEvent::UserActivity)?;
assert_eq!(authentication.state()?.remaining_seconds(), 30);
let editor = authentication.begin_entry_editor("email/personal")?;
authentication.lifecycle(MobileLifecycleEvent::Background)?;
assert!(!authentication.state()?.unlocked());
assert!(authentication.entry_editor(editor.id()).is_err());
let baseline_locks = backend.locks();
drop(authentication);
assert!(
backend.locks() > baseline_locks,
"final owner locks the OS backend"
);
Ok(())
}
#[derive(Default)]
struct BackendState {
values: BTreeMap<SecretLocator, SecretBytes>,