[domistream] Tests: rustfmt
This commit is contained in:
@@ -7,7 +7,9 @@ mod common;
|
||||
|
||||
use common::{param, parse_query, xml_padded_to, xml_root};
|
||||
use domistream::Error;
|
||||
use domistream::http::xml::{self, MAX_XML_ATTRIBUTES, MAX_XML_BYTES, MAX_XML_DEPTH, MAX_XML_ELEMENTS, MAX_XML_TEXT_BYTES};
|
||||
use domistream::http::xml::{
|
||||
self, MAX_XML_ATTRIBUTES, MAX_XML_BYTES, MAX_XML_DEPTH, MAX_XML_ELEMENTS, MAX_XML_TEXT_BYTES,
|
||||
};
|
||||
use domistream::http::{self, Scheme};
|
||||
use proptest::prelude::*;
|
||||
|
||||
@@ -92,7 +94,10 @@ fn xml_refuses_non_documents() {
|
||||
(br#"<root status_code="200">&#xZZ;</root>"#, "bad hex reference"),
|
||||
(br#"<root status_code="200"><a b="<"/></root>"#, "< in attribute value"),
|
||||
(br#"<!DOCTYPE root><root status_code="200"/>"#, "DTD"),
|
||||
(br#"<?xml version="1.0"?><!DOCTYPE r [<!ENTITY a "aaaa">]><root status_code="200">&a;</root>"#, "entity declaration"),
|
||||
(
|
||||
br#"<?xml version="1.0"?><!DOCTYPE r [<!ENTITY a "aaaa">]><root status_code="200">&a;</root>"#,
|
||||
"entity declaration",
|
||||
),
|
||||
(br#"<root status_code="200"><?pi data?></root>"#, "processing instruction in the body"),
|
||||
(br#" <?xml version="1.0"?><root status_code="200"/>"#, "XML declaration not at the start"),
|
||||
(br#"<root xmlns:a="urn:x" status_code="200"><a:b/></root>"#, "namespaces"),
|
||||
@@ -249,9 +254,8 @@ fn tree(depth: u32) -> impl Strategy<Value = Tree> {
|
||||
children: vec![],
|
||||
});
|
||||
leaf.prop_recursive(depth, 24, 4, move |inner| {
|
||||
("[a-wA-W][a-zA-Z0-9_]{0,6}", attrs.clone(), "[ -~]{0,8}", proptest::collection::vec(inner, 0..4)).prop_map(
|
||||
|(name, attrs, text, children)| Tree { name, attrs, text, children },
|
||||
)
|
||||
("[a-wA-W][a-zA-Z0-9_]{0,6}", attrs.clone(), "[ -~]{0,8}", proptest::collection::vec(inner, 0..4))
|
||||
.prop_map(|(name, attrs, text, children)| Tree { name, attrs, text, children })
|
||||
})
|
||||
}
|
||||
|
||||
@@ -457,9 +461,15 @@ fn applist_caps() {
|
||||
let app = |i: usize, title: &str| format!("<App><AppTitle>{title}</AppTitle><ID>{i}</ID></App>");
|
||||
let t = "t".repeat(MAX_APP_TITLE_BYTES);
|
||||
assert_eq!(http::parse_app_list(&xml_root(200, &app(1, &t))).unwrap()[0].title, t);
|
||||
assert_cap!(http::parse_app_list(&xml_root(200, &app(1, &"t".repeat(MAX_APP_TITLE_BYTES + 1)))), MAX_APP_TITLE_BYTES);
|
||||
assert_cap!(
|
||||
http::parse_app_list(&xml_root(200, &app(1, &"t".repeat(MAX_APP_TITLE_BYTES + 1)))),
|
||||
MAX_APP_TITLE_BYTES
|
||||
);
|
||||
// Multi-byte titles: the cap is in bytes.
|
||||
assert_cap!(http::parse_app_list(&xml_root(200, &app(1, &"é".repeat(MAX_APP_TITLE_BYTES / 2 + 1)))), MAX_APP_TITLE_BYTES);
|
||||
assert_cap!(
|
||||
http::parse_app_list(&xml_root(200, &app(1, &"é".repeat(MAX_APP_TITLE_BYTES / 2 + 1)))),
|
||||
MAX_APP_TITLE_BYTES
|
||||
);
|
||||
|
||||
let list = |n: usize| (0..n).map(|i| app(i, "g")).collect::<String>();
|
||||
assert_eq!(http::parse_app_list(&xml_root(200, &list(MAX_APPS))).unwrap().len(), MAX_APPS);
|
||||
@@ -470,8 +480,16 @@ fn applist_caps() {
|
||||
let apps = http::parse_app_list(&xml_padded_to(&inner, len)).unwrap_or_else(|e| panic!("{len}: {e:?}"));
|
||||
assert_eq!(apps.len(), 1, "unknown elements are ignored");
|
||||
}
|
||||
assert_too_large!(http::parse_app_list(&xml_padded_to(&inner, MAX_APPLIST_BYTES + 1)), MAX_APPLIST_BYTES, MAX_APPLIST_BYTES + 1);
|
||||
assert_too_large!(http::parse_app_list(&vec![b'<'; 3 * MAX_APPLIST_BYTES]), MAX_APPLIST_BYTES, 3 * MAX_APPLIST_BYTES);
|
||||
assert_too_large!(
|
||||
http::parse_app_list(&xml_padded_to(&inner, MAX_APPLIST_BYTES + 1)),
|
||||
MAX_APPLIST_BYTES,
|
||||
MAX_APPLIST_BYTES + 1
|
||||
);
|
||||
assert_too_large!(
|
||||
http::parse_app_list(&vec![b'<'; 3 * MAX_APPLIST_BYTES]),
|
||||
MAX_APPLIST_BYTES,
|
||||
3 * MAX_APPLIST_BYTES
|
||||
);
|
||||
}
|
||||
|
||||
// ================================================================================================ launch
|
||||
@@ -605,7 +623,10 @@ fn launch_params() -> http::LaunchParams {
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
fps: 60,
|
||||
keys: domistream::SessionKeys { rikey: *b"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff", rikeyid: 1_234_567 },
|
||||
keys: domistream::SessionKeys {
|
||||
rikey: *b"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
|
||||
rikeyid: 1_234_567,
|
||||
},
|
||||
hdr: false,
|
||||
audio: http::launch::AudioLayout::Stereo,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user