fmt the envelope-marker test

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ExUfAkYbq8UC9pQCiLy8TQ
This commit is contained in:
rustdesk
2026-08-07 11:56:03 +08:00
parent eed7052d1d
commit 137bb362f2
+13 -5
View File
@@ -1078,22 +1078,30 @@ mod tests {
fn test_endpoint_ice_policy_declaration() { fn test_endpoint_ice_policy_declaration() {
// An envelope with the marker declares full ICE; everything else — no marker, // An envelope with the marker declares full ICE; everything else — no marker,
// wrong value, foreign scheme, garbage — reads as the old Relay-only semantics. // wrong value, foreign scheme, garbage — reads as the old Relay-only semantics.
let marked = WebRTCStream::sdp_to_endpoint(r#"{"type":"offer","sdp":"v=0","ice_policy":"all"}"#); let marked =
WebRTCStream::sdp_to_endpoint(r#"{"type":"offer","sdp":"v=0","ice_policy":"all"}"#);
assert!(WebRTCStream::endpoint_declares_all_ice(&marked)); assert!(WebRTCStream::endpoint_declares_all_ice(&marked));
let unmarked = WebRTCStream::sdp_to_endpoint(r#"{"type":"offer","sdp":"v=0"}"#); let unmarked = WebRTCStream::sdp_to_endpoint(r#"{"type":"offer","sdp":"v=0"}"#);
assert!(!WebRTCStream::endpoint_declares_all_ice(&unmarked)); assert!(!WebRTCStream::endpoint_declares_all_ice(&unmarked));
let wrong = WebRTCStream::sdp_to_endpoint(r#"{"type":"offer","sdp":"v=0","ice_policy":"relay"}"#); let wrong =
WebRTCStream::sdp_to_endpoint(r#"{"type":"offer","sdp":"v=0","ice_policy":"relay"}"#);
assert!(!WebRTCStream::endpoint_declares_all_ice(&wrong)); assert!(!WebRTCStream::endpoint_declares_all_ice(&wrong));
assert!(!WebRTCStream::endpoint_declares_all_ice("")); assert!(!WebRTCStream::endpoint_declares_all_ice(""));
assert!(!WebRTCStream::endpoint_declares_all_ice("webrtc://not-base64!")); assert!(!WebRTCStream::endpoint_declares_all_ice(
assert!(!WebRTCStream::endpoint_declares_all_ice("https://example.com")); "webrtc://not-base64!"
));
assert!(!WebRTCStream::endpoint_declares_all_ice(
"https://example.com"
));
// The marker must be invisible to the plain RTCSessionDescription parse old peers do. // The marker must be invisible to the plain RTCSessionDescription parse old peers do.
let sdp_json = WebRTCStream::get_remote_offer(&marked).unwrap(); let sdp_json = WebRTCStream::get_remote_offer(&marked).unwrap();
serde_json::from_str::<webrtc::peer_connection::sdp::session_description::RTCSessionDescription>(&sdp_json) serde_json::from_str::<
webrtc::peer_connection::sdp::session_description::RTCSessionDescription,
>(&sdp_json)
.expect("extra envelope key must not break RTCSessionDescription parsing"); .expect("extra envelope key must not break RTCSessionDescription parsing");
} }