Implement structured Android entry viewer (#99)
This commit is contained in:
1 parent
647dc1bb4b
commit
c0ba6d43d8
29 files changed
+1768
-78
No files matched your search
@@ -740,6 +740,79 @@ fn mobile_expiry_and_user_input_never_reveal_old_editor_handles() -> TestResult
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn presented_field_ids_reject_replaced_documents_and_ticks_do_not_renew_the_lease() -> TestResult {
|
||||
use ironstorage::{
|
||||
config::Config,
|
||||
mobile_authentication::{MobileAuthentication, MobileAuthenticationErrorKind},
|
||||
};
|
||||
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",
|
||||
vault.path().to_str().unwrap(),
|
||||
fixture.path("keys").to_str().unwrap(),
|
||||
fixture.key("alice")?.primary_fingerprint
|
||||
),
|
||||
)?;
|
||||
let clock = ManualClock::default();
|
||||
let authentication = MobileAuthentication::with_platform(
|
||||
Config::load(Some(&source))?,
|
||||
Arc::new(MemoryBackend::default()),
|
||||
Arc::new(clock.clone()),
|
||||
)?;
|
||||
authentication.set_authentication_timeout(2)?;
|
||||
authentication.unlock_entry(
|
||||
"email/personal",
|
||||
Some(SecretBytes::new(
|
||||
fixture.key("alice")?.passphrase.as_bytes().to_vec(),
|
||||
)),
|
||||
)?;
|
||||
let page = authentication.entry_page("email/personal", 59)?;
|
||||
let id = page.page().sections()[0].fields()[0].id();
|
||||
assert!(
|
||||
!authentication
|
||||
.reveal_presented_entry_field("email/personal", id, page.page().revision())?
|
||||
.is_empty()
|
||||
);
|
||||
clock.advance(Duration::from_secs(1));
|
||||
authentication.refresh_entry_presentation("email/personal", page.page().revision(), 60)?;
|
||||
assert_eq!(authentication.state()?.remaining_seconds(), 1);
|
||||
authentication.replace_entry_field("email/personal", id, "changed password".to_owned())?;
|
||||
let error = authentication
|
||||
.replace_presented_entry_field(
|
||||
"email/personal",
|
||||
id,
|
||||
page.page().revision(),
|
||||
"must not overwrite".to_owned(),
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(error.kind(), MobileAuthenticationErrorKind::Conflict);
|
||||
assert!(!authentication.state()?.unlocked());
|
||||
authentication.unlock_entry(
|
||||
"email/personal",
|
||||
Some(SecretBytes::new(
|
||||
fixture.key("alice")?.passphrase.as_bytes().to_vec(),
|
||||
)),
|
||||
)?;
|
||||
assert_eq!(
|
||||
authentication.reveal_entry_field("email/personal", id)?,
|
||||
"changed password"
|
||||
);
|
||||
clock.advance(Duration::from_secs(2));
|
||||
assert!(
|
||||
authentication
|
||||
.refresh_entry_presentation("email/personal", page.page().revision(), 61)
|
||||
.is_err()
|
||||
);
|
||||
assert!(!authentication.state()?.unlocked());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn locking_interrupts_an_os_prompt_before_waiting_for_the_lease_mutex() -> TestResult {
|
||||
struct PromptBackend {
|
||||
|
||||
Reference in new issue
Block a user