Share the platform-neutral Rust mobile contract (#91)
Dependency security audit / rustsec (push) Failing after 22s
Dependency security audit / rustsec (push) Failing after 22s
This commit is contained in:
1 parent
fcb36a0684
commit
180851087b
52 files changed
+8932
-4263
No files matched your search
@@ -17,9 +17,11 @@ fn apple_sources_preserve_the_mobile_security_boundary() {
|
||||
let watch = workspace_file("apple/Sources/Watch/IronStorageWatchApp.swift");
|
||||
let autofill = workspace_file("apple/Sources/AutoFill/CredentialProviderViewController.swift");
|
||||
let bridges = format!(
|
||||
"{}\n{}",
|
||||
"{}\n{}\n{}\n{}",
|
||||
workspace_file("crates/apple/src/lib.rs"),
|
||||
workspace_file("crates/watch-apple/src/lib.rs")
|
||||
workspace_file("crates/watch-apple/src/lib.rs"),
|
||||
workspace_file("crates/mobile-bridge/src/lib.rs"),
|
||||
workspace_file("crates/mobile-bridge/src/platform.rs")
|
||||
);
|
||||
|
||||
for (name, source) in [
|
||||
|
||||
@@ -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>,
|
||||
|
||||
@@ -183,7 +183,7 @@ fn complex_documents_round_trip_with_storage_owned_metadata() -> TestResult {
|
||||
assert_eq!(mobile_custom[1].value(), Some(""));
|
||||
let mobile_otp = mobile_fields
|
||||
.iter()
|
||||
.find(|field| field.system_image() == "timer")
|
||||
.find(|field| field.icon() == ironstorage::mobile::MobileIcon::Timer)
|
||||
.expect("OTP field");
|
||||
assert!(mobile_otp.sensitive());
|
||||
assert_eq!(mobile_otp.value(), None);
|
||||
@@ -192,7 +192,7 @@ fn complex_documents_round_trip_with_storage_owned_metadata() -> TestResult {
|
||||
}));
|
||||
let mobile_note = mobile_fields
|
||||
.iter()
|
||||
.find(|field| field.system_image() == "note.text")
|
||||
.find(|field| field.icon() == ironstorage::mobile::MobileIcon::Note)
|
||||
.expect("multiline note");
|
||||
assert!(!mobile_note.sensitive());
|
||||
assert!(mobile_note.multiline());
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
const WORKSPACE: &str = include_str!("../../../Cargo.toml");
|
||||
const STORAGE_MANIFEST: &str = include_str!("../Cargo.toml");
|
||||
const APPLE_MANIFEST: &str = include_str!("../../apple/Cargo.toml");
|
||||
const ANDROID_MANIFEST: &str = include_str!("../../android/Cargo.toml");
|
||||
const MOBILE_MANIFEST: &str = include_str!("../../mobile-bridge/Cargo.toml");
|
||||
const CLI_MANIFEST: &str = include_str!("../../../apps/cli/Cargo.toml");
|
||||
const TUI_MANIFEST: &str = include_str!("../../../apps/tui/Cargo.toml");
|
||||
const DESKTOP_MANIFEST: &str = include_str!("../../../apps/desktop/Cargo.toml");
|
||||
@@ -18,8 +20,16 @@ fn release_feature_and_advisory_boundaries_stay_explicit() {
|
||||
for manifest in [CLI_MANIFEST, TUI_MANIFEST, DESKTOP_MANIFEST] {
|
||||
assert!(manifest.contains("features = [\"ssh\"]"));
|
||||
}
|
||||
assert!(APPLE_MANIFEST.contains("default-features = false, features = [\"full\"]"));
|
||||
assert!(!APPLE_MANIFEST.contains("features = [\"ssh\"]"));
|
||||
assert!(MOBILE_MANIFEST.contains("default-features = false, features = [\"full\"]"));
|
||||
assert!(
|
||||
APPLE_MANIFEST.contains(
|
||||
"ironstorage-mobile = { path = \"../mobile-bridge\", features = [\"watch\"] }"
|
||||
)
|
||||
);
|
||||
assert!(ANDROID_MANIFEST.contains("ironstorage-mobile = { path = \"../mobile-bridge\" }"));
|
||||
for manifest in [APPLE_MANIFEST, ANDROID_MANIFEST, MOBILE_MANIFEST] {
|
||||
assert!(!manifest.contains("features = [\"ssh\"]"));
|
||||
}
|
||||
assert!(AUDIT_WORKFLOW.contains("tool: rust@1.92.0,cargo-audit@0.22.2"));
|
||||
assert!(AUDIT_WORKFLOW.contains("fallback: none"));
|
||||
assert!(!AUDIT_WORKFLOW.contains("cargo install"));
|
||||
|
||||
Reference in new issue
Block a user