Revamp desktop usability and multiline fields

This commit is contained in:
2026-08-10 22:06:16 +02:00
parent 40b15a9713
commit aeb18b488f
12 changed files with 1283 additions and 545 deletions

View File

@@ -1534,7 +1534,7 @@ mod tests {
RemoveRequest, ShowRequest,
},
config::Config,
crypto::KeyInfo,
crypto::{KeyInfo, KeyStore},
git::{GitCredentialProvider as _, GitIdentity, GitRepository},
otp::OtpInput,
presentation::{ClipboardTimeout, QrMatrix},
@@ -1903,6 +1903,55 @@ mod tests {
Ok(())
}
#[test]
fn cli_terminal_show_preserves_multiline_field_bytes() -> TestResult {
const FINGERPRINT: &str = "7E5C5241B25F6FFAAD717EBFA132DCB2DC23AE30";
let fixtures = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../crates/storage/tests/fixtures/compatibility");
let temporary = tempfile::tempdir()?;
let vault = temporary.path().join("vault");
fs::create_dir(&vault)?;
fs::write(vault.join(".gpg-id"), format!("{FINGERPRINT}\n"))?;
let repository = Repository::open(&vault)?;
let keys = KeyStore::load(fixtures.join("keys"))?;
let recipients = keys.resolve_recipients(format!("{FINGERPRINT}\n").as_bytes())?;
let plaintext =
b"password\ncomments: Recovery codes:\none\ntwo\nurl: https://example.test\n";
let ciphertext = keys.encrypt(SecretBytes::new(plaintext.to_vec()), &recipients)?;
repository.write_entry(&EntryPath::parse("documents/multiline")?, &ciphertext)?;
let config_path = temporary.path().join("config.toml");
fs::write(
&config_path,
format!(
"vault = {:?}\ndefault_key = {:?}\nkey_material = {:?}\n",
vault,
FINGERPRINT,
fixtures.join("keys"),
),
)?;
let config = Config::load(Some(&config_path))?;
let mut secrets = fixture_secrets(FINGERPRINT)?;
let mut stdout = Vec::new();
let mut stderr = Vec::new();
assert_eq!(
execute_secure(
&config,
&CommandRequest::Show(ShowRequest {
entry: Some("documents/multiline".to_owned()),
presentation: Presentation::Terminal,
}),
&mut secrets,
&mut stdout,
&mut stderr,
)
.expect("memory output cannot fail"),
EXIT_SUCCESS
);
assert_eq!(stdout, plaintext);
assert!(stderr.is_empty());
Ok(())
}
#[test]
fn cli_prompts_for_a_missing_openpgp_passphrase_then_stores_and_reuses_it() -> TestResult {
const FINGERPRINT: &str = "7E5C5241B25F6FFAAD717EBFA132DCB2DC23AE30";