test: keep offline update and key-exchange downgrade rejections

Restore three tests that are the only coverage of their rejection class:

- offline update metadata rejects a signed artifact with an http or
  credential-bearing URL;
- offline verification rejects a renamed local file and a version that
  does not match the release;
- a key-exchange pick lowered in transit leaves both sides unable to
  decrypt, so a v0 fallback after a failed v1 decrypt cannot pass
  unnoticed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WS1HTjp6UQuG43KEcQPq1R
This commit is contained in:
rustdesk
2026-10-14 13:54:01 +08:00
co-authored by Claude Opus 5.5
parent 3461b17c60
commit 23909ded5b
2 changed files with 39 additions and 0 deletions
+9
View File
@@ -5835,4 +5835,13 @@ mod kx_tests {
assert_eq!(seen.picked, 0);
assert!(seen.decrypted && decrypted);
}
#[tokio::test]
async fn test_a_pick_lowered_in_transit_decrypts_nothing() {
// The controlled side takes 0 from a controller without versions, so a lowered pick is
// caught by the keys disagreeing on the first application message, not before.
let (seen, decrypted) = handshake(KX_VERSION_LATEST, Some(0)).await;
assert_eq!(seen.picked, 1);
assert!(!seen.decrypted && !decrypted);
}
}
+30
View File
@@ -53,3 +53,33 @@ fn accepts_signed_offline_artifact_from_custom_https_release() {
assert_eq!("rustdesk-1.4.6-x86_64.exe", artifact.file_name);
}
#[test]
fn rejects_signed_offline_artifact_from_unsafe_url() {
for url in [
"http://updates.example.com/rustdesk-1.4.6-x86_64.exe",
"https://user@updates.example.com/rustdesk-1.4.6-x86_64.exe",
] {
let mut invalid_metadata = metadata();
invalid_metadata["artifacts"][0]["url"] = json!(url);
let fixture = sign_fixture(invalid_metadata, KEY_ID);
assert!(
verify_offline(&fixture, "rustdesk-1.4.6-x86_64.exe").is_err(),
"{url}"
);
}
}
#[test]
fn rejects_offline_artifact_name_or_release_mismatch() {
assert!(verify_offline(&valid_fixture(), "renamed-update.exe").is_err());
let mut invalid_metadata = metadata();
invalid_metadata["version"] = json!("1.4.7");
assert!(verify_offline(
&sign_fixture(invalid_metadata, KEY_ID),
"rustdesk-1.4.6-x86_64.exe"
)
.is_err());
}