[domistream] HTTP: test that a full applist at MAX_APPS fits the XML element cap (fails: 4096 apps need 16385 elements)

Hosts write four elements per app; MAX_APPS of them plus the root must fit MAX_XML_ELEMENTS, so the app cap is reachable.
This commit is contained in:
2026-12-04 12:56:26 +01:00
parent c06fec4be5
commit 3dd7a8fe94
+18
View File
@@ -497,6 +497,24 @@ fn applist_caps() {
); );
} }
#[test]
fn applist_cap_is_reachable_with_full_apps() {
// Hosts write four elements per app (App, AppTitle, ID, IsHdrSupported; the host writer does too): a list of
// MAX_APPS such apps plus the root must fit the XML element cap, so a list at the app cap parses (one app more is
// refused, by whichever cap comes first; `applist_caps` checks the app cap itself with three-element apps).
use domistream::http::applist::MAX_APPS;
let full = |n: usize| {
(0..n)
.map(|i| format!("<App><AppTitle>g</AppTitle><ID>{i}</ID><IsHdrSupported>1</IsHdrSupported></App>"))
.collect::<String>()
};
assert!(1 + 4 * MAX_APPS <= MAX_XML_ELEMENTS, "root + 4 per app = {} elements", 1 + 4 * MAX_APPS);
let apps = http::parse_app_list(&xml_root(200, &full(MAX_APPS))).expect("a full list at the app cap");
assert_eq!(apps.len(), MAX_APPS);
assert!(apps.iter().all(|a| a.hdr_supported));
assert_err!(http::parse_app_list(&xml_root(200, &full(MAX_APPS + 1))), Error::TooLarge { .. });
}
// ================================================================================================ launch // ================================================================================================ launch
#[test] #[test]