From a635ec23459a29bbe4d4b1ed6f4d5e9b7954d5f0 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Wed, 25 Oct 2023 19:13:48 -0300 Subject: [PATCH] feat(cli): add unit test for empty updater private key password (#8096) --- tooling/cli/src/helpers/updater_signature.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tooling/cli/src/helpers/updater_signature.rs b/tooling/cli/src/helpers/updater_signature.rs index 82923a229471..972659dd8981 100644 --- a/tooling/cli/src/helpers/updater_signature.rs +++ b/tooling/cli/src/helpers/updater_signature.rs @@ -165,3 +165,19 @@ where .map_err(|e| minisign::PError::new(minisign::ErrorKind::Io, e))?; Ok(BufReader::new(file)) } + +#[cfg(test)] +mod tests { + const PRIVATE_KEY: &str = "dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5dkpDN09RZm5GeVAzc2RuYlNzWVVJelJRQnNIV2JUcGVXZUplWXZXYXpqUUFBQkFBQUFBQUFBQUFBQUlBQUFBQTZrN2RnWGh5dURxSzZiL1ZQSDdNcktiaHRxczQwMXdQelRHbjRNcGVlY1BLMTBxR2dpa3I3dDE1UTVDRDE4MXR4WlQwa1BQaXdxKy9UU2J2QmVSNXhOQWFDeG1GSVllbUNpTGJQRkhhTnROR3I5RmdUZi90OGtvaGhJS1ZTcjdZU0NyYzhQWlQ5cGM9Cg=="; + + // we use minisign=0.7.3 to prevent a breaking change + #[test] + fn empty_password_is_valid() { + let path = std::env::temp_dir().join("minisign-password-text.txt"); + std::fs::write(&path, b"TAURI").expect("failed to write test file"); + + let secret_key = + super::secret_key(PRIVATE_KEY.into(), Some("".into())).expect("failed to resolve secret key"); + super::sign_file(&secret_key, &path).expect("failed to sign file"); + } +}