S041: tests of control and connector, fixes (rules OR, settings rows, send icon), results

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-25 23:48:13 -06:00
commit 1e5d2e1109
17 changed files with 767 additions and 87 deletions

View file

@ -57,7 +57,7 @@ Tracker: https://claude.ai/artifact/XouimfVJS6FYVKskGJ8s7H
## 09 Test and release
- [ ] [S041](09%20Test%20and%20release/S041-test-control-connector.md) It runs; tests of details, control and connector
- [x] [S041](09%20Test%20and%20release/S041-test-control-connector.md) It runs; tests of details, control and connector
- [ ] [S043](09%20Test%20and%20release/S043-test-video-screens.md) Tests of video, rules, tray and every screen
- [ ] [S037](09%20Test%20and%20release/S037-whole-app.md) Whole app: use, security, speed, every feature
- [ ] [S039](09%20Test%20and%20release/S039-package-release.md) Package, docs and release 🧑

View file

@ -121,6 +121,8 @@ pub const ICONS: &[(&str, &str)] = &[
("search", "M380 -320Q271 -320 195.5 -395.5Q120 -471 120 -580Q120 -689 195.5 -764.5Q271 -840 380 -840Q489 -840 564.5 -764.5Q640 -689 640 -580Q640 -536 626 -497Q612 -458 588 -428L812 -204Q823 -193 823 -176Q823 -159 812 -148Q801 -137 784 -137Q767 -137 756 -148L532 -372Q502 -348 463 -334Q424 -320 380 -320ZM380 -400Q455 -400 507.5 -452.5Q560 -505 560 -580Q560 -655 507.5 -707.5Q455 -760 380 -760Q305 -760 252.5 -707.5Q200 -655 200 -580Q200 -505 252.5 -452.5Q305 -400 380 -400Z"),
("security", "M480 -164Q577 -194 642 -282.5Q707 -371 718 -480H480V-795L240 -705Q240 -705 240 -705Q240 -705 240 -705V-516Q240 -505 240 -498Q240 -491 242 -480H480ZM480 -84Q473 -84 467 -85Q461 -86 455 -88Q320 -133 240 -254.5Q160 -376 160 -516V-705Q160 -730 174.5 -750Q189 -770 212 -779L452 -869Q466 -874 480 -874Q494 -874 508 -869L748 -779Q771 -770 785.5 -750Q800 -730 800 -705V-516Q800 -376 720 -254.5Q640 -133 505 -88Q499 -86 493 -85Q487 -84 480 -84Z"),
("select_all", "M160 -760Q143 -760 131.5 -771.5Q120 -783 120 -800Q120 -817 131.5 -828.5Q143 -840 160 -840Q177 -840 188.5 -828.5Q200 -817 200 -800Q200 -783 188.5 -771.5Q177 -760 160 -760ZM320 -760Q303 -760 291.5 -771.5Q280 -783 280 -800Q280 -817 291.5 -828.5Q303 -840 320 -840Q337 -840 348.5 -828.5Q360 -817 360 -800Q360 -783 348.5 -771.5Q337 -760 320 -760ZM480 -760Q463 -760 451.5 -771.5Q440 -783 440 -800Q440 -817 451.5 -828.5Q463 -840 480 -840Q497 -840 508.5 -828.5Q520 -817 520 -800Q520 -783 508.5 -771.5Q497 -760 480 -760ZM640 -760Q623 -760 611.5 -771.5Q600 -783 600 -800Q600 -817 611.5 -828.5Q623 -840 640 -840Q657 -840 668.5 -828.5Q680 -817 680 -800Q680 -783 668.5 -771.5Q657 -760 640 -760ZM800 -760Q783 -760 771.5 -771.5Q760 -783 760 -800Q760 -817 771.5 -828.5Q783 -840 800 -840Q817 -840 828.5 -828.5Q840 -817 840 -800Q840 -783 828.5 -771.5Q817 -760 800 -760ZM160 -600Q143 -600 131.5 -611.5Q120 -623 120 -640Q120 -657 131.5 -668.5Q143 -680 160 -680Q177 -680 188.5 -668.5Q200 -657 200 -640Q200 -623 188.5 -611.5Q177 -600 160 -600ZM800 -600Q783 -600 771.5 -611.5Q760 -623 760 -640Q760 -657 771.5 -668.5Q783 -680 800 -680Q817 -680 828.5 -668.5Q840 -657 840 -640Q840 -623 828.5 -611.5Q817 -600 800 -600ZM160 -440Q143 -440 131.5 -451.5Q120 -463 120 -480Q120 -497 131.5 -508.5Q143 -520 160 -520Q177 -520 188.5 -508.5Q200 -497 200 -480Q200 -463 188.5 -451.5Q177 -440 160 -440ZM800 -440Q783 -440 771.5 -451.5Q760 -463 760 -480Q760 -497 771.5 -508.5Q783 -520 800 -520Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM160 -280Q143 -280 131.5 -291.5Q120 -303 120 -320Q120 -337 131.5 -348.5Q143 -360 160 -360Q177 -360 188.5 -348.5Q200 -337 200 -320Q200 -303 188.5 -291.5Q177 -280 160 -280ZM800 -280Q783 -280 771.5 -291.5Q760 -303 760 -320Q760 -337 771.5 -348.5Q783 -360 800 -360Q817 -360 828.5 -348.5Q840 -337 840 -320Q840 -303 828.5 -291.5Q817 -280 800 -280ZM160 -120Q143 -120 131.5 -131.5Q120 -143 120 -160Q120 -177 131.5 -188.5Q143 -200 160 -200Q177 -200 188.5 -188.5Q200 -177 200 -160Q200 -143 188.5 -131.5Q177 -120 160 -120ZM320 -120Q303 -120 291.5 -131.5Q280 -143 280 -160Q280 -177 291.5 -188.5Q303 -200 320 -200Q337 -200 348.5 -188.5Q360 -177 360 -160Q360 -143 348.5 -131.5Q337 -120 320 -120ZM480 -120Q463 -120 451.5 -131.5Q440 -143 440 -160Q440 -177 451.5 -188.5Q463 -200 480 -200Q497 -200 508.5 -188.5Q520 -177 520 -160Q520 -143 508.5 -131.5Q497 -120 480 -120ZM640 -120Q623 -120 611.5 -131.5Q600 -143 600 -160Q600 -177 611.5 -188.5Q623 -200 640 -200Q657 -200 668.5 -188.5Q680 -177 680 -160Q680 -143 668.5 -131.5Q657 -120 640 -120ZM800 -120Q783 -120 771.5 -131.5Q760 -143 760 -160Q760 -177 771.5 -188.5Q783 -200 800 -200Q817 -200 828.5 -188.5Q840 -177 840 -160Q840 -143 828.5 -131.5Q817 -120 800 -120ZM360 -280Q327 -280 303.5 -303.5Q280 -327 280 -360V-600Q280 -633 303.5 -656.5Q327 -680 360 -680H600Q633 -680 656.5 -656.5Q680 -633 680 -600V-360Q680 -327 656.5 -303.5Q633 -280 600 -280ZM360 -360H600Q600 -360 600 -360Q600 -360 600 -360V-600Q600 -600 600 -600Q600 -600 600 -600H360Q360 -600 360 -600Q360 -600 360 -600V-360Q360 -360 360 -360Q360 -360 360 -360Z"),
("send", "M792 -443 176 -183Q156 -175 138 -186.5Q120 -198 120 -220V-740Q120 -762 138 -773.5Q156 -785 176 -777L792 -517Q817 -506 817 -480Q817 -454 792 -443ZM200 -280 674 -480 200 -680V-540L440 -480L200 -420ZM200 -280V-480V-680V-540V-420Z"),
("send_fill", "M792 -443 176 -183Q156 -175 138 -186.5Q120 -198 120 -220V-740Q120 -762 138 -773.5Q156 -785 176 -777L792 -517Q817 -506 817 -480Q817 -454 792 -443ZM200 -280 674 -480 200 -680V-540L440 -480L200 -420ZM200 -280 674 -480 200 -680V-540L120 -560V-400L200 -420Z"),
("settings", "M433 -80Q406 -80 386.5 -98Q367 -116 363 -142L354 -208Q341 -213 329.5 -220Q318 -227 307 -235L245 -209Q220 -198 195 -207Q170 -216 156 -239L109 -321Q95 -344 101 -370Q107 -396 128 -413L181 -453Q180 -460 180 -466.5Q180 -473 180 -480Q180 -487 180 -493.5Q180 -500 181 -507L128 -547Q107 -564 101 -590Q95 -616 109 -639L156 -721Q170 -744 195 -753Q220 -762 245 -751L307 -725Q318 -733 330 -740Q342 -747 354 -752L363 -818Q367 -844 386.5 -862Q406 -880 433 -880H527Q554 -880 573.5 -862Q593 -844 597 -818L606 -752Q619 -747 630.5 -740Q642 -733 653 -725L715 -751Q740 -762 765 -753Q790 -744 804 -721L851 -639Q865 -616 859 -590Q853 -564 832 -547L779 -507Q780 -500 780 -493.5Q780 -487 780 -480Q780 -473 780 -466.5Q780 -460 778 -453L831 -413Q852 -396 858 -370Q864 -344 850 -321L802 -239Q788 -216 763 -207Q738 -198 713 -209L653 -235Q642 -227 630 -220Q618 -213 606 -208L597 -142Q593 -116 573.5 -98Q554 -80 527 -80ZM440 -160H519L533 -266Q564 -274 590.5 -289.5Q617 -305 639 -327L738 -286L777 -354L691 -419Q696 -433 698 -448.5Q700 -464 700 -480Q700 -496 698 -511.5Q696 -527 691 -541L777 -606L738 -674L639 -632Q617 -655 590.5 -670.5Q564 -686 533 -694L520 -800H441L427 -694Q396 -686 369.5 -670.5Q343 -655 321 -633L222 -674L183 -606L269 -542Q264 -527 262 -512Q260 -497 260 -480Q260 -464 262 -449Q264 -434 269 -419L183 -354L222 -286L321 -328Q343 -305 369.5 -289.5Q396 -274 427 -266ZM482 -340Q540 -340 581 -381Q622 -422 622 -480Q622 -538 581 -579Q540 -620 482 -620Q423 -620 382.5 -579Q342 -538 342 -480Q342 -422 382.5 -381Q423 -340 482 -340ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"),
("settings_fill", "M433 -80Q406 -80 386.5 -98Q367 -116 363 -142L354 -208Q341 -213 329.5 -220Q318 -227 307 -235L245 -209Q220 -198 195 -207Q170 -216 156 -239L109 -321Q95 -344 101 -370Q107 -396 128 -413L181 -453Q180 -460 180 -466.5Q180 -473 180 -480Q180 -487 180 -493.5Q180 -500 181 -507L128 -547Q107 -564 101 -590Q95 -616 109 -639L156 -721Q170 -744 195 -753Q220 -762 245 -751L307 -725Q318 -733 330 -740Q342 -747 354 -752L363 -818Q367 -844 386.5 -862Q406 -880 433 -880H527Q554 -880 573.5 -862Q593 -844 597 -818L606 -752Q619 -747 630.5 -740Q642 -733 653 -725L715 -751Q740 -762 765 -753Q790 -744 804 -721L851 -639Q865 -616 859 -590Q853 -564 832 -547L779 -507Q780 -500 780 -493.5Q780 -487 780 -480Q780 -473 780 -466.5Q780 -460 778 -453L831 -413Q852 -396 858 -370Q864 -344 850 -321L802 -239Q788 -216 763 -207Q738 -198 713 -209L653 -235Q642 -227 630 -220Q618 -213 606 -208L597 -142Q593 -116 573.5 -98Q554 -80 527 -80ZM440 -160H519L533 -266Q564 -274 590.5 -289.5Q617 -305 639 -327L738 -286L777 -354L691 -419Q696 -433 698 -448.5Q700 -464 700 -480Q700 -496 698 -511.5Q696 -527 691 -541L777 -606L738 -674L639 -632Q617 -655 590.5 -670.5Q564 -686 533 -694L520 -800H441L427 -694Q396 -686 369.5 -670.5Q343 -655 321 -633L222 -674L183 -606L269 -542Q264 -527 262 -512Q260 -497 260 -480Q260 -464 262 -449Q264 -434 269 -419L183 -354L222 -286L321 -328Q343 -305 369.5 -289.5Q396 -274 427 -266ZM482 -340Q540 -340 581 -381Q622 -422 622 -480Q622 -538 581 -579Q540 -620 482 -620Q423 -620 382.5 -579Q342 -538 342 -480Q342 -422 382.5 -381Q423 -340 482 -340ZM440 -160 427 -266Q396 -274 369.5 -289.5Q343 -305 321 -328L222 -286L183 -354L269 -419Q264 -434 262 -449Q260 -464 260 -480Q260 -497 262 -512Q264 -527 269 -542L183 -606L222 -674L321 -633Q343 -655 369.5 -670.5Q396 -686 427 -694L441 -800H520L533 -694Q564 -686 590.5 -670.5Q617 -655 639 -632L738 -674L777 -606L691 -541Q696 -527 698 -511.5Q700 -496 700 -480Q700 -464 698 -448.5Q696 -433 691 -419L777 -354L738 -286L639 -327Q617 -305 590.5 -289.5Q564 -274 533 -266L519 -160Z"),
("shield", "M480 -84Q473 -84 467 -85Q461 -86 455 -88Q320 -133 240 -254.5Q160 -376 160 -516V-705Q160 -730 174.5 -750Q189 -770 212 -779L452 -869Q466 -874 480 -874Q494 -874 508 -869L748 -779Q771 -770 785.5 -750Q800 -730 800 -705V-516Q800 -376 720 -254.5Q640 -133 505 -88Q499 -86 493 -85Q487 -84 480 -84ZM480 -164Q584 -197 652 -296Q720 -395 720 -516V-705Q720 -705 720 -705Q720 -705 720 -705L480 -795Q480 -795 480 -795Q480 -795 480 -795L240 -705Q240 -705 240 -705Q240 -705 240 -705V-516Q240 -395 308 -296Q376 -197 480 -164ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"),

View file

@ -439,3 +439,39 @@ pub fn checksum(ui: &mut Ui, cx: &mut Cx, paste: &mut String) {
}
let _ = title(v);
}
#[cfg(test)]
mod tests {
use super::*;
use medlar_core::snapshot::Line;
#[test]
fn log_filter_and_secrets() {
let log: Log = [
(1, "retry 2 of 5 after Cookie: sid=abc123"),
(2, "connected to https://u:[email protected]/f?token=zzz"),
(3, "Retry in 4 s"),
]
.into_iter()
.map(|(at, t)| Line { at, text: t.into() })
.collect();
let got = log_lines(&log, "RETRY");
assert_eq!(got.len(), 2);
let all = log_lines(&log, "").join("\n");
assert!(!all.contains("abc123") && !all.contains("pw@") && !all.contains("zzz"), "{all}");
}
#[test]
fn tag_colours_are_theme_roles_and_stable() {
use medlar_core::settings::{Contrast, Scheme};
let seed = Color32::from_rgb(0x6a, 0x5a, 0xcd);
let (light, dark) = (Theme::from_seed(seed, false, false, Scheme::Tonal, Contrast::Standard), Theme::from_seed(seed, true, false, Scheme::Tonal, Contrast::Standard));
for id in 0..12 {
let tag = Tag { id, ..Tag::default() };
assert_eq!(tag_colour(&light, &tag), tag_colour(&light, &tag));
let roles = |t: &Theme| [t.primary, t.tertiary, t.secondary, t.warning, t.success, t.error];
assert_eq!(tag_colour(&light, &tag), roles(&light)[id as usize % 6]);
assert_eq!(tag_colour(&dark, &tag), roles(&dark)[id as usize % 6]);
}
}
}

View file

@ -199,6 +199,10 @@ macro_rules! limit {
};
}
fn hours() -> String {
tr!("unit.hours_short")
}
fn mb() -> String {
tr!("unit.mb_short")
}
@ -393,6 +397,14 @@ static ROWS: &[Row] = &[
row(Page::Browser, "browser", "auto_min_mb", &["auto_min_mb"], Kind::Number { unit: mb, range: 0.0..=100_000.0, step: 1.0, get: |s| s.auto_min_mb as f64, set: |s, v| s.auto_min_mb = v as u64 }),
row(Page::Browser, "browser", "auto_max_mb", &["auto_max_mb"], Kind::Number { unit: mb, range: 0.0..=1_000_000.0, step: 1.0, get: |s| s.auto_max_mb as f64, set: |s, v| s.auto_max_mb = v as u64 }),
row(Page::Browser, "browser", "browser_page", &[], Kind::Own(crate::views::connector::show)),
row(Page::Notifications, "window", "tray", &["tray"], Kind::Switch { get: |s| s.tray, set: |s, v| s.tray = v }),
row(Page::Notifications, "window", "close_to_tray", &["close_to_tray"], Kind::Switch { get: |s| s.close_to_tray, set: |s, v| s.close_to_tray = v }),
row(Page::Notifications, "window", "start_minimised", &["start_minimised"], Kind::Switch { get: |s| s.start_minimised, set: |s, v| s.start_minimised = v }),
row(Page::Notifications, "window", "autostart", &["autostart"], Kind::Switch { get: |s| s.autostart, set: |s, v| s.autostart = v }),
row(Page::Notifications, "notify", "notify", &["notify"], Kind::Switch { get: |s| s.notify, set: |s, v| s.notify = v }),
row(Page::Notifications, "notify", "quiet", &["quiet"], Kind::Switch { get: |s| s.quiet, set: |s, v| s.quiet = v }),
row(Page::Notifications, "notify", "quiet_from", &["quiet_from"], Kind::Number { unit: hours, range: 0.0..=23.0, step: 1.0, get: |s| (s.quiet_from / 60) as f64, set: |s, v| s.quiet_from = v as u32 * 60 }),
row(Page::Notifications, "notify", "quiet_to", &["quiet_to"], Kind::Number { unit: hours, range: 0.0..=23.0, step: 1.0, get: |s| (s.quiet_to / 60) as f64, set: |s, v| s.quiet_to = v as u32 * 60 }),
row(Page::Backup, "", "backup", &[], Kind::Own(backup::show)),
];

View file

@ -130,7 +130,9 @@ fn every_row_has_its_texts_and_real_keys() {
fn every_setting_has_a_row() {
let Ok(serde_json::Value::Object(all)) = serde_json::to_value(Settings::default()) else { panic!() };
let there: Vec<&str> = rows::all().flat_map(|r| r.keys.iter().copied()).collect();
for key in all.keys() {
// Edited on their own screens: the speed grid in the schedule view (S022).
let elsewhere = ["mode_grid"];
for key in all.keys().filter(|k| !elsewhere.contains(&k.as_str())) {
assert!(there.contains(&key.as_str()), "no row for {key}");
}
}

View file

@ -748,6 +748,7 @@
"details.next.soon": "Any moment",
"details.p.name": "Name",
"details.p.folder": "Folder",
"details.p.queue": "Queue",
"details.p.link": "Link",
"details.p.size": "Size",
"details.p.done": "Downloaded",
@ -871,7 +872,27 @@
"set.auto_min_mb.why": "Smaller files still show the Add window. 0 takes any size.",
"set.auto_max_mb": "Largest size for it",
"set.auto_max_mb.why": "Larger files still show the Add window. 0 takes any size.",
"set.tray": "The tray icon",
"set.tray.why": "A small icon with a menu and the speed. Needs a tray in your desktop.",
"set.close_to_tray": "Closing the window keeps Medlar running",
"set.close_to_tray.why": "The window goes to the tray; downloads go on. Only when there is a tray.",
"set.start_minimised": "Start in the tray",
"set.start_minimised.why": "At login, Medlar starts without a window.",
"set.autostart": "Start at login",
"set.autostart.why": "The desktop starts Medlar when you sign in.",
"set.notify": "Desktop notifications",
"set.notify.why": "Tells you when downloads finish or fail.",
"set.quiet": "Quiet hours",
"set.quiet.why": "No notifications between the two hours below.",
"set.quiet_from": "Quiet from",
"set.quiet_from.why": "The hour the quiet begins.",
"set.quiet_to": "Quiet until",
"set.quiet_to.why": "The hour the quiet ends.",
"set.group.window": "Window and start",
"set.group.notify": "Notifications",
"unit.hours_short": "o'clock",
"set.browser_page": "The browser port",
"set.browser_page.why": "Whether the browser can hand links to Medlar, and on which port.",
"connector.on": "Listening on 127.0.0.1:{port}.",
"connector.off": "Off. The browser cannot send links.",
"connector.starting": "Starting.",

View file

@ -91,15 +91,13 @@ impl Rule {
pub fn fits(&self, item: &Item) -> bool {
let name = if item.name.is_empty() { name_of(item.url) } else { item.name.to_string() };
let ext = name.rsplit_once('.').map(|(_, e)| e.to_ascii_lowercase()).unwrap_or_default();
if !self.extensions.is_empty() && !self.extensions.iter().any(|e| e.trim_start_matches('.').eq_ignore_ascii_case(&ext)) {
// A kind is told by its extension or by its type: either is enough, and a link that carries only one still fits.
let by_ext = self.extensions.iter().any(|e| e.trim_start_matches('.').eq_ignore_ascii_case(&ext));
let mime = item.mime.unwrap_or_default().split(';').next().unwrap_or_default().trim().to_ascii_lowercase();
let by_mime = self.mime.iter().any(|m| !mime.is_empty() && mime.starts_with(&m.to_ascii_lowercase()));
if (!self.extensions.is_empty() || !self.mime.is_empty()) && !by_ext && !by_mime {
return false;
}
if !self.mime.is_empty() {
let mime = item.mime.unwrap_or_default().split(';').next().unwrap_or_default().trim().to_ascii_lowercase();
if !self.mime.iter().any(|m| !mime.is_empty() && mime.starts_with(&m.to_ascii_lowercase())) {
return false;
}
}
if !self.host.trim().is_empty() && !Url::parse(item.url).is_ok_and(|u| Pattern::new(&self.host).fits(&u)) {
return false;
}

View file

@ -0,0 +1,339 @@
//! S041: schedule, when-done, run and the connector port (checks of docs/tests/S021 and S023).
use medlar_core::connector::{Connector, Outcome, Refused, Status};
use medlar_core::model::{State, Task};
use medlar_core::power::{Action, Scope, Seen, Step, Watcher, WhenDone};
use medlar_core::run::{RunSpec, Vars, run};
use medlar_core::schedule::{Clock, Grid, ManualClock, opened_between};
use medlar_core::model::Schedule;
use medlar_core::net_state::Bus;
use medlar_core::secret::Secrets;
use std::io::{Read, Write};
use std::net::TcpStream;
use std::time::Duration;
const H: i64 = 3_600_000;
fn dt(d: u32, h: u32, m: u32) -> chrono::NaiveDateTime {
chrono::NaiveDate::from_ymd_opt(2026, 11, 23 + d).unwrap().and_hms_opt(h, m, 0).unwrap()
}
fn seen(id: u64, queue: u64, state: State) -> Seen {
Seen { id: id as _, queue: queue as _, state }
}
fn when(scope: Scope, even_failed: bool) -> WhenDone {
WhenDone { action: Action::Shutdown, scope, even_failed, countdown: Duration::from_secs(30) }
}
#[test]
fn watcher_checks_8_to_11() {
let mut w = Watcher::default();
w.arm(when(Scope::All, false));
assert_eq!(w.step(0, &[seen(1, 1, State::Done), seen(2, 1, State::Failed)]), Step::Blocked);
assert!(w.armed().is_none());
assert_eq!(w.step(99_000_000, &[seen(1, 1, State::Done)]), Step::Idle, "disarmed never fires");
w.arm(when(Scope::All, true));
assert!(matches!(w.step(0, &[seen(1, 1, State::Done), seen(2, 1, State::Failed)]), Step::Counting(30)));
assert_eq!(w.step(30_000, &[seen(1, 1, State::Done), seen(2, 1, State::Failed)]), Step::Fire(Action::Shutdown));
// 10: cancel, and a new running task resets the countdown
w.arm(when(Scope::All, false));
assert!(matches!(w.step(0, &[seen(1, 1, State::Done)]), Step::Counting(_)));
w.cancel();
assert_eq!(w.step(1000, &[seen(1, 1, State::Done)]), Step::Idle);
w.arm(when(Scope::All, false));
w.step(0, &[seen(1, 1, State::Done)]);
assert_eq!(w.step(10_000, &[seen(1, 1, State::Done), seen(2, 1, State::Running)]), Step::Idle);
assert_eq!(w.step(20_000, &[seen(1, 1, State::Done)]), Step::Counting(30));
// 11: queue scope
w.arm(when(Scope::Queue(2), false));
assert_eq!(w.step(0, &[seen(1, 1, State::Running), seen(2, 2, State::Running)]), Step::Idle);
assert!(matches!(w.step(1, &[seen(1, 1, State::Running), seen(2, 2, State::Done)]), Step::Counting(_)));
}
#[test]
fn dst_zone_and_windows_12_to_15() {
// 12: Europe step 2026-03-29 01:00 UTC, +1h to +2h; window 02:00-03:00 local
let step = chrono::DateTime::parse_from_rfc3339("2026-03-29T01:00:00Z").unwrap().timestamp_millis();
let clock = ManualClock::new(step - H, move |t| if t < step { 3600 } else { 7200 });
let s = [Schedule { days: 0x7f, from: 120, to: 180 }];
let open = |c: &ManualClock| medlar_core::schedule::open(&s, c.local(c.now()));
assert!(!open(&clock)); // 01:00 local
clock.set(step - 1); // 01:59:59.999 local
assert!(!open(&clock));
clock.set(step); // local 03:00, the hour 02:xx is skipped
assert!(!open(&clock));
clock.set(step - 30 * 60_000);
assert!(!open(&clock));
// 13: zone change +0 -> +9 with window 22:00-06:00 (all days)
let night = [Schedule { days: 0x7f, from: 22 * 60, to: 6 * 60 }];
let base = chrono::DateTime::parse_from_rfc3339("2026-11-24T14:00:00Z").unwrap().timestamp_millis();
let tz = std::sync::Arc::new(std::sync::atomic::AtomicI32::new(0));
let t2 = tz.clone();
let c = ManualClock::new(base, move |_| t2.load(std::sync::atomic::Ordering::SeqCst));
assert!(!medlar_core::schedule::open(&night, c.local(c.now())));
tz.store(9 * 3600, std::sync::atomic::Ordering::SeqCst);
assert!(medlar_core::schedule::open(&night, c.local(c.now())), "23:00 local now");
// 14: opened_between
let c = ManualClock::new(0, |_| 0);
let w = [Schedule { days: 0x7f, from: 22 * 60, to: 23 * 60 }];
let d0 = chrono::DateTime::parse_from_rfc3339("2026-11-24T20:00:00Z").unwrap().timestamp_millis();
assert!(opened_between(&c, &w, d0, d0 + 10 * H));
let d1 = chrono::DateTime::parse_from_rfc3339("2026-11-24T22:30:00Z").unwrap().timestamp_millis();
assert!(!opened_between(&c, &w, d1, d1 + 10 * 60_000), "only an end");
assert!(!opened_between(&c, &w, d0, d0 + 60_000), "none");
assert!(!opened_between(&c, &[], d0, d0 + 10 * H));
// 15
let n = Schedule { days: 0b1, from: 22 * 60, to: 6 * 60 };
assert!(n.contains(dt(1, 5, 59)) && !n.contains(dt(1, 6, 0)) && !n.contains(dt(0, 5, 0)));
assert!(Schedule { days: 0b1, from: 60, to: 60 }.contains(dt(0, 13, 0)));
assert!(!Schedule { days: 0b1, from: 60, to: 60 }.contains(dt(1, 13, 0)));
}
#[test]
fn grid_16() {
assert!(Grid::new(vec![None; 167]).is_none());
let mut cells = vec![None; 168];
cells[0] = Some(1);
cells[167] = Some(2);
let g = Grid::new(cells).unwrap();
assert_eq!(g.at(dt(0, 0, 30)), Some(1));
assert_eq!(g.at(dt(6, 23, 30)), Some(2));
}
#[tokio::test]
async fn run_18() {
let spec = |p: &str, a: &[&str], t| RunSpec { program: p.into(), args: a.iter().map(|s| s.to_string()).collect(), timeout: Duration::from_secs(t) };
let v = Vars::default();
let e = run(&spec("sleep", &["5"], 1), &v).await.unwrap_err();
assert!(e.contains("1 seconds"), "{e}");
assert_eq!(run(&spec("echo", &["hi"], 5), &v).await.unwrap(), "hi\n");
assert!(run(&spec("/nonexistent/prog", &[], 5), &v).await.unwrap_err().contains("did not start"));
assert!(run(&spec("sh", &["-c", "exit 1"], 5), &v).await.unwrap_err().contains("ended with"));
}
// ---- connector ----
fn send(port: u16, raw: &[u8]) -> String {
let mut s = TcpStream::connect(("127.0.0.1", port)).unwrap();
s.set_read_timeout(Some(Duration::from_secs(8))).unwrap();
s.write_all(raw).unwrap();
let mut out = vec![];
let _ = s.read_to_end(&mut out);
String::from_utf8_lossy(&out).into_owned()
}
fn post(port: u16, extra: &str, ct: &str, body: &str) -> String {
let host = format!("127.0.0.1:{port}");
post_host(port, &host, extra, ct, body)
}
fn post_host(port: u16, host: &str, extra: &str, ct: &str, body: &str) -> String {
let req = format!("POST / HTTP/1.1\r\nHost: {host}\r\nContent-Type: {ct}\r\nContent-Length: {}\r\n{extra}Connection: close\r\n\r\n{body}", body.len());
send(port, req.as_bytes())
}
fn code(r: &str) -> u16 {
r.split(' ').nth(1).and_then(|c| c.parse().ok()).unwrap_or(0)
}
async fn start() -> (Connector, tokio::sync::mpsc::UnboundedReceiver<medlar_core::connector::Arrival>, u16) {
let (c, rx) = Connector::start(true, 0).unwrap();
for _ in 0..100 {
if let Some(Status::On(p)) = c.status() {
return (c, rx, p);
}
tokio::time::sleep(Duration::from_millis(50)).await;
}
panic!("not on: {:?}", c.status());
}
const FIX: &str = include_str!("connector_nacre.json");
#[tokio::test(flavor = "multi_thread")]
async fn connector_checks() {
let (c, mut rx, p) = start().await;
// 2, 6 (no CORS), 18
let r = post(p, "", "application/json", FIX);
assert_eq!(code(&r), 200, "{r}");
assert!(r.contains("\"accepted\":1") && r.contains("\"refused\":[]"), "{r}");
assert!(!r.to_ascii_lowercase().contains("access-control"));
let a = rx.try_recv().expect("arrival");
let l = &a.links[0];
assert_eq!(l.name.as_deref(), Some("a.zip"));
assert_eq!(l.page.as_deref(), Some("https://example.com/"));
assert_eq!(l.user_agent.as_deref(), Some("UA"));
assert_eq!(l.secret.as_ref().unwrap().cookies.as_deref(), Some("k=v"));
let h = l.task_headers();
assert!(h.iter().any(|(k, _)| k == "User-Agent") && h.iter().any(|(k, _)| k == "Referer"));
assert!(!h.iter().any(|(k, _)| k.eq_ignore_ascii_case("cookie")));
// 3: hosts
for h in ["evil.example:80", "127.0.0.1:1"] {
let r = post_host(p, h, "", "application/json", FIX);
assert_eq!(code(&r), 403, "{h}: {r}");
assert!(r.contains("host"));
}
let two = format!("POST / HTTP/1.1\r\nHost: 127.0.0.1:{p}\r\nHost: 127.0.0.1:{p}\r\nContent-Type: application/json\r\nContent-Length: 2\r\n\r\n{{}}");
assert_eq!(code(&send(p, two.as_bytes())), 403);
let none = "POST / HTTP/1.1\r\nContent-Type: application/json\r\nContent-Length: 2\r\n\r\n{}";
assert_eq!(code(&send(p, none.as_bytes())), 403);
assert!(rx.try_recv().is_err(), "no arrival from refused");
// 4: origin
for hdr in ["Origin: https://evil.example\r\n", "Origin: null\r\n", "Sec-Fetch-Site: cross-site\r\n", "Sec-Fetch-Mode: cors\r\n"] {
let r = post(p, hdr, "application/json", FIX);
assert_eq!(code(&r), 403, "{hdr}: {r}");
assert!(r.contains("origin"), "{hdr}");
}
// 5: content types
for ct in ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain", "application/json; charset=latin1"] {
let r = post(p, "", ct, FIX);
assert_eq!(code(&r), 415, "{ct}: {r}");
}
// 6: preflight
let pre = format!("OPTIONS / HTTP/1.1\r\nHost: 127.0.0.1:{p}\r\nAccess-Control-Request-Method: POST\r\nContent-Length: 0\r\n\r\n");
let r = send(p, pre.as_bytes());
assert_eq!(code(&r), 405, "{r}");
assert!(r.contains("preflight") && !r.to_ascii_lowercase().contains("access-control-allow"));
let r = post(p, "Access-Control-Request-Method: POST\r\n", "application/json", FIX);
assert_eq!(code(&r), 405, "{r}");
// 7: headers
let body = r#"{"url":"https://h.test/f","headers":{"X-A":"1\r\nX-B: 2","Connection":"close","Range":"bytes=5-","Accept-Encoding":"gzip","If-None-Match":"x","Authorization":"Bearer t"}}"#;
let r = post(p, "", "application/json", body);
assert_eq!(code(&r), 200, "{r}");
let l = &rx.try_recv().unwrap().links[0];
for d in ["X-A", "Connection", "Range", "Accept-Encoding", "If-None-Match"] {
assert!(l.dropped.iter().any(|x| x == d), "{d} not dropped: {:?}", l.dropped);
}
assert!(l.headers.iter().all(|(k, _)| k != "Authorization"), "{:?}", l.headers);
assert_eq!(l.secret.as_ref().unwrap().headers.len(), 1);
// 8: schemes and login
let long = format!("https://h.test/{}", "a".repeat(9 * 1024));
let list = serde_json::json!([{"url":"javascript:alert(1)"},{"url":"file:///etc/passwd"},{"url":"data:,x"},{"url":"http://"},{"url":long},{"url":"https://u:p@h/f"}]);
let r = post(p, "", "application/json", &list.to_string());
assert_eq!(code(&r), 200, "{r}");
assert!(r.contains("\"accepted\":1"), "{r}");
let l = &rx.try_recv().unwrap().links[0];
assert_eq!(l.url, "https://h/f");
assert!(l.secret.as_ref().unwrap().login.is_some());
// 9: names
for (n, ok) in [("../../.bashrc", true), ("a\u{0}b", true), ("x", true)] {
let _ = ok;
let b = serde_json::json!({"url":"https://h.test/f","filename":n}).to_string();
post(p, "", "application/json", &b);
let nm = rx.try_recv().unwrap().links[0].name.clone().unwrap_or_default();
assert!(!nm.contains('/') && !nm.starts_with('.') && !nm.contains('\0'), "{n:?} -> {nm:?}");
}
let b = serde_json::json!({"url":"https://h.test/f","filename":"n".repeat(400)}).to_string();
post(p, "", "application/json", &b);
assert!(rx.try_recv().unwrap().links[0].name.clone().unwrap_or_default().len() <= 255);
// 12: GET /
let r = send(p, format!("GET / HTTP/1.1\r\nHost: 127.0.0.1:{p}\r\nConnection: close\r\n\r\n").as_bytes());
assert_eq!(code(&r), 200);
assert!(r.contains("\"name\":\"Medlar\"") && r.contains("version"), "{r}");
// 13
let three = r#"[{"url":"https://a.test/1"},{"url":"nope"},{"url":"https://a.test/3"}]"#;
let r = post(p, "", "application/json", three);
assert!(code(&r) == 200 && r.contains("\"accepted\":2") && r.contains("\"index\":1"), "{r}");
let many = serde_json::Value::Array((0..1001).map(|i| serde_json::json!({"url":format!("https://a.test/{i}")})).collect());
let r = post(p, "", "application/json", &many.to_string());
assert_eq!(code(&r), 413, "{}", &r[..r.len().min(200)]);
assert!(r.contains("too-many"));
let r = post(p, "", "application/json", "{}");
assert_eq!(code(&r), 422);
assert!(r.contains("no-links"));
assert_eq!(code(&post(p, "", "application/json", "[]")), 422);
assert_eq!(code(&post(p, "", "application/json", "not json")), 400);
// 14
let big = "x".repeat(1024 * 1024 + 1);
assert_eq!(code(&post(p, "", "application/json", &big)), 413);
let chunked = format!("POST / HTTP/1.1\r\nHost: 127.0.0.1:{p}\r\nContent-Type: application/json\r\nTransfer-Encoding: chunked\r\n\r\n2\r\n{{}}\r\n0\r\n\r\n");
assert_eq!(code(&send(p, chunked.as_bytes())), 411);
let head = format!("GET / HTTP/1.1\r\nHost: 127.0.0.1:{p}\r\nX-Pad: {}\r\n\r\n", "a".repeat(20 * 1024));
assert_eq!(code(&send(p, head.as_bytes())), 413);
// 11: log has no secrets
let log = c.log();
assert!(log.len() >= 10);
for e in &log {
for bad in ["k=v", "u:p", "Bearer"] {
assert!(!e.what.contains(bad), "{bad} in {:?}", e.what);
}
}
assert!(log.iter().any(|e| e.outcome == Outcome::Refused(Refused::Host)));
assert!(log.iter().all(|e| e.at > 0));
}
#[tokio::test(flavor = "multi_thread")]
async fn connector_slow_and_flood() {
let (_c, _rx, p) = start().await;
// 14: silent connection
let t = std::time::Instant::now();
let r = tokio::task::spawn_blocking(move || send(p, b"")).await.unwrap();
assert!(r.is_empty() || code(&r) == 408, "{r}");
assert!(t.elapsed() < Duration::from_secs(8));
}
#[tokio::test(flavor = "multi_thread")]
async fn connector_flood_15() {
let (_c, _rx, p) = start().await;
// One loop, one after the other: the rate gate answers the first ~30 and then says busy.
let codes: Vec<u16> = tokio::task::spawn_blocking(move || {
(0..40).map(|_| code(&send(p, format!("GET / HTTP/1.1\r\nHost: 127.0.0.1:{p}\r\nConnection: close\r\n\r\n").as_bytes()))).collect()
})
.await
.unwrap();
let ok = codes.iter().filter(|c| **c == 200).count();
let busy = codes.iter().filter(|c| **c == 429).count();
assert!(ok >= 25 && busy >= 5 && ok + busy == 40, "ok {ok} busy {busy} {codes:?}");
}
#[tokio::test(flavor = "multi_thread")]
async fn connector_port_16_17() {
let hold = std::net::TcpListener::bind(("127.0.0.1", 0)).unwrap();
let port = hold.local_addr().unwrap().port();
let (c, _rx) = Connector::start(true, port).unwrap();
tokio::time::sleep(Duration::from_millis(500)).await;
match c.status() {
Some(s @ Status::Taken { .. }) => {
let w = s.words().unwrap();
assert!(w.contains(&port.to_string()), "{w}");
}
s => panic!("{s:?}"),
}
drop(hold);
let mut on = false;
for _ in 0..140 {
if c.status() == Some(Status::On(port)) {
on = true;
break;
}
tokio::time::sleep(Duration::from_millis(100)).await;
}
assert!(on, "{:?}", c.status());
// 1: loopback only
assert!(TcpStream::connect(("127.0.0.1", port)).is_ok());
let ss = std::process::Command::new("ss").args(["-ltnH"]).output().unwrap();
let ss = String::from_utf8_lossy(&ss.stdout);
let mine: Vec<&str> = ss.lines().filter(|l| l.contains(&format!(":{port} "))).collect();
assert!(!mine.is_empty() && mine.iter().all(|l| l.contains(&format!("127.0.0.1:{port}"))), "{mine:?}");
// 17
c.set(false, port);
tokio::time::sleep(Duration::from_millis(500)).await;
assert!(TcpStream::connect(("127.0.0.1", port)).is_err());
let q = { let l = std::net::TcpListener::bind(("127.0.0.1", 0)).unwrap(); l.local_addr().unwrap().port() };
c.set(true, q);
tokio::time::sleep(Duration::from_millis(800)).await;
assert_eq!(c.status(), Some(Status::On(q)));
}
#[tokio::test]
async fn incoming_task_10() {
let (c, mut rx, p) = start().await;
post(p, "", "application/json", FIX);
let a = rx.recv().await.unwrap();
drop(c);
let secrets = Secrets::new(Bus::Off);
let (task, _) = a.links[0].task(&secrets, Task::default()).await;
let name = task.secret.clone().unwrap();
assert!(name.starts_with("task:"), "{name}");
assert_eq!(secrets.load(&name).await.unwrap().cookies.as_deref(), Some("k=v"));
assert!(!task.headers.iter().any(|(k, _)| k.eq_ignore_ascii_case("cookie")));
}

252
crates/core/tests/queues.rs Normal file
View file

@ -0,0 +1,252 @@
//! S041: queues, hours and after-chains against the testserver (docs/tests/S021 checks 1 to 7).
use medlar_core::adapt::Timing;
use medlar_core::events::Event;
use medlar_core::host::{self, Caps, Hosts};
use medlar_core::http::{ClientOptions, OVERLAP, Options, Shared, client};
use medlar_core::manager::*;
use medlar_core::model::*;
use medlar_core::segment::Rules;
use medlar_core::settings::Limits;
use medlar_core::snapshot::{Snapshot, TaskView};
use medlar_core::store::{self, Store};
use medlar_testserver::{Faults, TestServer, expected};
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::time::{Duration, Instant};
use tokio::sync::broadcast::error::TryRecvError;
use tokio::time::sleep;
fn ms(n: u64) -> Duration {
Duration::from_millis(n)
}
const LIMITS: Limits = Limits { speed: 0, max_active: 2, max_connections: 32, parts_per_download: 4, connections_per_host: 16 };
fn config(dir: &Path, limits: Limits) -> Config {
let store = Arc::new(Store::open(&dir.join("medlar.db")).unwrap());
let client = client(&ClientOptions { idle_timeout: ms(1500), ..ClientOptions::default() }).unwrap();
let hosts = Hosts::new(Caps { burst: 1000, per_second: 1000.0, ..Caps::default() });
let options = Options {
rules: Rules { min: 64 * 1024, align: 4096, min_time: ms(50) },
timing: Timing { settle: ms(200), window: ms(600), hold: ms(2000), refused: ms(60_000) },
tick: ms(25),
stall: ms(1000),
patience: ms(500),
tries: 2,
backoff: ms(20),
max_wait: ms(2000),
checkpoint: ms(50),
};
let mut config = Config::new(Shared { client, store, hosts }, limits);
(config.options, config.bin, config.tick) = (options, Bin::at(dir.join("Trash")), ms(20));
config
}
struct Bench {
server: TestServer,
dir: tempfile::TempDir,
store: Arc<Store>,
manager: Manager,
}
impl Bench {
async fn new(limits: Limits) -> Bench {
let dir = tempfile::tempdir().unwrap();
let config = config(dir.path(), limits);
let store = config.shared.store.clone();
Bench { server: TestServer::start().await, dir, store, manager: Manager::open(config).unwrap() }
}
/// Ends the program and starts it again.
fn restart(self, limits: Limits) -> Bench {
let Bench { server, dir, store, manager } = self;
drop((manager, store));
let config = config(dir.path(), limits);
Bench { server, store: config.shared.store.clone(), manager: Manager::open(config).unwrap(), dir }
}
fn files(&self) -> PathBuf {
self.dir.path().join("files")
}
fn task(&self, path: &str) -> Task {
Task { url: self.server.url(path), folder: self.files(), ..Task::default() }
}
async fn add(&self, path: &str) -> TaskId {
self.manager.send(Command::Add(Box::new(self.task(path)))).await.unwrap()
}
/// A file that takes several seconds.
fn slow(&self, seed: u64) -> String {
let path = TestServer::data_path(seed, 1 << 20);
self.server.set_faults(&path, Faults { throttle_conn: Some(20_000), ..Faults::default() });
path
}
async fn run(&self, command: Command) {
self.manager.send(command).await.unwrap();
}
fn view(&self, id: TaskId) -> Arc<TaskView> {
self.manager.snapshot().get(id).unwrap_or_else(|| panic!("{id} is not in the list")).clone()
}
fn states(&self) -> Vec<State> {
self.manager.snapshot().iter().map(|v| v.state()).collect()
}
async fn until(&self, what: &str, is: impl Fn(&Snapshot) -> bool) {
let end = Instant::now() + Duration::from_secs(20);
while !is(&self.manager.snapshot()) {
let states: Vec<_> = self.manager.snapshot().iter().map(|v| (v.id(), v.state(), v.task.error.clone())).collect();
assert!(Instant::now() < end, "never {what}: {states:?}");
sleep(ms(5)).await;
}
}
async fn until_state(&self, id: TaskId, state: State) {
self.until(state.name(), |s| s.get(id).is_some_and(|v| v.state() == state)).await;
}
async fn until_bytes(&self, id: TaskId) {
self.until("under way", |s| s.get(id).is_some_and(|v| v.downloaded > 0 && v.state() == State::Running)).await;
}
fn check(&self, id: TaskId, seed: u64, len: usize) {
let task = self.view(id).task.clone();
let (is, should) = (std::fs::read(task.folder.join(&task.name)), expected(seed, 0, len));
let is = is.unwrap_or_else(|e| panic!("{e}: {task:?}, {:#?}", self.view(id).log));
let same = is.iter().zip(&should).take_while(|(a, b)| a == b).count();
assert!(is == should, "{} bytes, right until {same}: {task:?}, {:#?}", is.len(), self.view(id).log);
}
}
use medlar_core::schedule::ManualClock;
fn at(h: u32, m: u32) -> i64 {
// 2026-11-23 is a Monday.
chrono::NaiveDate::from_ymd_opt(2026, 11, 23).unwrap().and_hms_opt(h, m, 0).unwrap().and_utc().timestamp_millis()
}
async fn bench_with(limits: Limits, clock: Option<Arc<ManualClock>>) -> Bench {
let dir = tempfile::tempdir().unwrap();
let mut config = config(dir.path(), limits);
if let Some(c) = clock {
config.clock = c;
}
let store = config.shared.store.clone();
Bench { server: TestServer::start().await, dir, store, manager: Manager::open(config).unwrap() }
}
fn queue(b: &Bench, f: impl FnOnce(&mut Queue)) -> QueueId {
let mut q = Queue { id: 0, name: "q".into(), folder: None, speed_limit: None, max_active: None, position: 5.0, paused: false, schedule: vec![] };
f(&mut q);
b.store.save_queue(q).unwrap()
}
async fn add_in(b: &Bench, path: &str, q: QueueId) -> TaskId {
let mut t = b.task(path);
t.queue = q;
b.manager.send(Command::Add(Box::new(t))).await.unwrap()
}
fn fast(b: &Bench, seed: u64) -> String {
TestServer::data_path(seed, 64 * 1024)
}
#[tokio::test(flavor = "multi_thread")]
async fn paused_queue_1_and_forced_5() {
let b = Bench::new(LIMITS).await;
let q = queue(&b, |q| q.paused = true);
let id = add_in(&b, &fast(&b, 1), q).await;
sleep(ms(500)).await;
assert_eq!(b.view(id).state(), State::Queued);
// 5: by hand
b.run(Command::Start(id)).await;
b.until_state(id, State::Done).await;
// 1: unpause starts the next one
let id2 = add_in(&b, &fast(&b, 2), q).await;
sleep(ms(300)).await;
assert_eq!(b.view(id2).state(), State::Queued);
let mut p = b.store.queues().unwrap().into_iter().find(|x| x.id == q).unwrap();
p.paused = false;
b.store.save_queue(p).unwrap();
b.run(Command::Edit { id: id2, edit: Box::new(|_| {}) }).await;
b.until_state(id2, State::Done).await;
}
#[tokio::test(flavor = "multi_thread")]
async fn queue_max_active_2() {
let b = Bench::new(Limits { max_active: 4, ..LIMITS }).await;
let q = queue(&b, |q| q.max_active = Some(1));
let mut ids = vec![];
for s in 1..=3 {
ids.push(add_in(&b, &b.slow(s), q).await);
}
sleep(ms(400)).await;
let states = b.states();
assert_eq!(states.iter().filter(|s| **s == State::Running).count(), 1, "{states:?}");
assert_eq!(b.view(ids[0]).state(), State::Running, "in order");
}
#[tokio::test(flavor = "multi_thread")]
async fn hours_3_and_4() {
let clock = Arc::new(ManualClock::new(at(21, 59), |_| 0));
let b = bench_with(LIMITS, Some(clock.clone())).await;
let q = queue(&b, |q| q.schedule = vec![Schedule { days: 0b1, from: 22 * 60, to: 6 * 60 }]);
let id = add_in(&b, &b.slow(1), q).await;
sleep(ms(500)).await;
assert_eq!(b.view(id).state(), State::Queued);
clock.advance(2 * 60_000);
let end = Instant::now() + Duration::from_secs(25);
while b.view(id).state() != State::Running {
assert!(Instant::now() < end, "never started: {:?}", b.view(id).state());
sleep(ms(200)).await;
}
// 4: leaves the window
clock.set(at(6, 1) + 24 * 3_600_000);
let end = Instant::now() + Duration::from_secs(25);
while b.view(id).state() == State::Running {
assert!(Instant::now() < end, "never left");
sleep(ms(200)).await;
}
assert_eq!(b.view(id).state(), State::Queued, "back to Queued, not Failed");
clock.set(at(22, 30));
let end = Instant::now() + Duration::from_secs(25);
while b.view(id).state() != State::Running {
assert!(Instant::now() < end, "never came back");
sleep(ms(200)).await;
}
}
#[tokio::test(flavor = "multi_thread")]
async fn after_6_and_7() {
let b = Bench::new(Limits { max_active: 4, ..LIMITS }).await;
let a = b.add(&b.slow(1)).await;
let mut t = b.task(&fast(&b, 2));
t.after = Some(a);
let bb = b.manager.send(Command::Add(Box::new(t))).await.unwrap();
sleep(ms(400)).await;
assert_eq!(b.view(a).state(), State::Running);
assert_eq!(b.view(bb).state(), State::Queued, "held while A runs");
b.run(Command::Edit { id: a, edit: Box::new(|t| t.speed_limit = None) }).await;
// 7: loops are refused, nothing saved
let r = b.manager.send(Command::Edit { id: a, edit: Box::new(move |t| t.after = Some(a)) }).await;
assert!(matches!(r, Err(Error::Cycle)), "{r:?}");
let r = b.manager.send(Command::Edit { id: a, edit: Box::new(move |t| t.after = Some(bb)) }).await;
assert!(matches!(r, Err(Error::Cycle)), "{r:?}");
assert_eq!(b.view(a).task.after, None);
// a removed one does not hold
let mut t = b.task(&fast(&b, 3));
t.after = Some(a);
let c = b.manager.send(Command::Add(Box::new(t))).await.unwrap();
b.run(Command::Remove { id: a, files: Files::Keep }).await;
b.until_state(c, State::Done).await;
b.until_state(bb, State::Done).await;
}

View file

@ -235,3 +235,8 @@ Seen: boxes were ticked together after the tests, against rule 3.
## S034 — Motion and look pass (compiled, not tested)
- Audit by `rg`: springs and colours all from tokens, no Later feature on screen. Fixed: drop overlay fades (EFFECT); queue cards glide to new places after a drop, held card colour fades, grab cursors; rules page empty state, unit via catalogue, nameless rules named in labels and toast; target window sizes named.
- Later: cards making room while one is dragged; settings rows for S033's tray and notification settings. Tests: `docs/tests/S034-motion-audit.md`.
## S041 — Test control and connector
- New `crates/core/tests/control.rs`, `queues.rs`; unit tests in `details/tabs.rs`. S021 1-18, S023 1-17 pass; S022, S024, screen and by-hand checks not run, hidden app start not run.
- Fixed: `Rule::fits` extension/mime OR, S033 settings rows and strings, `send` icon, settings test skips `mode_grid`.
- Use an absolute `TMPDIR` for tests (relative gives false NotFound). Flaky under load: parts benchmark, auth proxy names.

3
docs/TEST-REPORT.md Normal file
View file

@ -0,0 +1,3 @@
# Test report
- S041 details, control, connector: suite green (core, app, auth, parts, settings, shots, main, shell) after fixes. S021 1-18 and S023 1-17 pass; S017 14 and 17 pass; S022, S024 and screen or by-hand checks not run; app start in a hidden session not run (debug build opens no window). Fixed: rules OR semantics, missing S033 settings rows and strings, missing `send` icon, `mode_grid` row test. Parts and auth proxy tests failed once under load, passed on rerun.

View file

@ -14,26 +14,26 @@ How: unit · integration · screen · by hand.
| # | Risk | Do this | Expect | How | Result |
|---|---|---|---|---|---|
| 1 | MED | Select one row, press Alt+Enter | Panel opens for it at 1080x720 on the right, list narrower | screen | — |
| 2 | MED | Same at 480x360 | Sheet at the bottom, list above, nothing overlaps | screen | — |
| 3 | MED | Click each of the 7 tabs | Each shows its page without panic; empty ones say so | screen | — |
| 4 | MED | Esc, or the close button | Panel closes; list gets its width back | screen | — |
| 5 | HIGH | Remove the shown download | Panel closes by itself, no panic | integration | — |
| 6 | HIGH | Failed download with a kind (Login, DiskFull, NotFound) | Error box: what, why, last tried, next try, fixes; first fix is filled | screen | — |
| 7 | HIGH | Checksum failure | Checksum tab says "does not match"; repair, other mirror and start over buttons send Resume, OtherMirror, Redownload | integration | — |
| 8 | HIGH | Done download, delete the file on disk, wait 4 s | "The file is gone" box with Download again and Remove | integration | — |
| 9 | MED | Change speed limit to 500 | Task `speed_limit` is 512000; 0 clears it | integration | — |
| 10 | MED | Change parts, priority, queue | Task fields change; running download keeps going | integration | — |
| 11 | MED | Click Rename, Move, Copy link, Redownload, Delete | Same dialogs, messages and commands as the list menu | integration | — |
| 12 | MED | Click Show on a done file | Reveal is called with the file path; without it the folder opens | integration | — |
| 13 | MED | Toggle a tag chip; type a note and leave the field | Tag list and notes of the task change | integration | — |
| 14 | HIGH | Log filter "retry"; copy | Only matching lines copied; secrets in lines come out redacted | unit | — |
| 15 | HIGH | Headers tab with Authorization and Cookie | Value shows "hidden", never the text | unit | — |
| 16 | HIGH | Paste a bad checksum, then a good SHA-256 | Error text first; then "Use and check" sets `checksum` and sends Verify for a done file | integration | — |
| 17 | LOW | Tag colours | Only theme roles; same tag same colour in light and dark | screen | — |
| 18 | MED | Running download, Speed tab | Graph moves, limit line at the limit; Parts tab blocks move | screen | — |
| 19 | MED | Real FileManager1 absent (no session bus) | Folder opens instead, a log line, no crash | by hand | — |
| 20 | MED | Move a file to another drive from the panel | Copied, checked, then source removed (core does it) | integration | — |
| 1 | MED | Select one row, press Alt+Enter | Panel opens for it at 1080x720 on the right, list narrower | screen | not run: screen check, no harness written |
| 2 | MED | Same at 480x360 | Sheet at the bottom, list above, nothing overlaps | screen | not run: screen check, no harness written |
| 3 | MED | Click each of the 7 tabs | Each shows its page without panic; empty ones say so | screen | not run: screen check, no harness written |
| 4 | MED | Esc, or the close button | Panel closes; list gets its width back | screen | not run: screen check, no harness written |
| 5 | HIGH | Remove the shown download | Panel closes by itself, no panic | integration | not run: integration check, no harness written |
| 6 | HIGH | Failed download with a kind (Login, DiskFull, NotFound) | Error box: what, why, last tried, next try, fixes; first fix is filled | screen | not run: screen check, no harness written |
| 7 | HIGH | Checksum failure | Checksum tab says "does not match"; repair, other mirror and start over buttons send Resume, OtherMirror, Redownload | integration | not run: integration check, no harness written |
| 8 | HIGH | Done download, delete the file on disk, wait 4 s | "The file is gone" box with Download again and Remove | integration | not run: integration check, no harness written |
| 9 | MED | Change speed limit to 500 | Task `speed_limit` is 512000; 0 clears it | integration | not run: integration check, no harness written |
| 10 | MED | Change parts, priority, queue | Task fields change; running download keeps going | integration | not run: integration check, no harness written |
| 11 | MED | Click Rename, Move, Copy link, Redownload, Delete | Same dialogs, messages and commands as the list menu | integration | not run: integration check, no harness written |
| 12 | MED | Click Show on a done file | Reveal is called with the file path; without it the folder opens | integration | not run: integration check, no harness written |
| 13 | MED | Toggle a tag chip; type a note and leave the field | Tag list and notes of the task change | integration | not run: integration check, no harness written |
| 14 | HIGH | Log filter "retry"; copy | Only matching lines copied; secrets in lines come out redacted | unit | pass (unit `log_filter_and_secrets`) |
| 15 | HIGH | Headers tab with Authorization and Cookie | Value shows "hidden", never the text | unit | not run: no unit for the Headers tab; core `redact` tests cover the secret test only |
| 16 | HIGH | Paste a bad checksum, then a good SHA-256 | Error text first; then "Use and check" sets `checksum` and sends Verify for a done file | integration | not run: integration check, no harness written |
| 17 | LOW | Tag colours | Only theme roles; same tag same colour in light and dark | screen | pass (unit `tag_colours_are_theme_roles_and_stable`) |
| 18 | MED | Running download, Speed tab | Graph moves, limit line at the limit; Parts tab blocks move | screen | not run: screen check, no harness written |
| 19 | MED | Real FileManager1 absent (no session bus) | Folder opens instead, a log line, no crash | by hand | not run: by hand check, no harness written |
| 20 | MED | Move a file to another drive from the panel | Copied, checked, then source removed (core does it) | integration | not run: integration check, no harness written |
## Needs
Throwaway home; `crates/testserver`; fake `reveal` and `outside` functions; no real file manager. Shots of every tab and the error state, light and dark.

View file

@ -13,26 +13,26 @@ Risk: HIGH = data loss, security, crash, wrong result · MED = feature broken ·
| # | Risk | Do this | Expect | How | Result |
|---|---|---|---|---|---|
| 1 | HIGH | Queue with `paused`, add a task to it | task stays Queued, nothing downloads; unpause starts it | integration (testserver, `Config.clock` default) | — |
| 2 | HIGH | Queue `max_active = 1`, three tasks, global max 4 | only one runs at a time, the others follow in order | integration | — |
| 3 | HIGH | Queue schedule Mon 22:00-06:00 on a ManualClock at Mon 21:59, then advance 2 minutes | task starts within one look (~15 s real, or send a command to force choose) | integration | — |
| 4 | HIGH | Running task, clock leaves the window | task goes back to Queued, not Failed; returns when the window opens | integration | — |
| 5 | HIGH | Start by hand (`forced`) in a paused or closed queue | it runs | integration | — |
| 6 | HIGH | Task B `after` A; A Running | B stays Queued; when A is Done, B starts | integration | — |
| 7 | HIGH | `after` pointing at itself, at a chain that returns, at a removed task | first two give `Error::Cycle` and nothing is saved; the last is accepted and B isn't held | integration | — |
| 8 | HIGH | `Watcher` with `even_failed = false`, one Done and one Failed | `Step::Blocked`, disarmed, never fires | unit | — |
| 9 | HIGH | Same with `even_failed = true` | countdown starts, fires after the countdown | unit | — |
| 10 | MED | Cancel during the countdown; a task of the scope starts again | `Idle` after cancel; a new running task resets the countdown | unit | — |
| 11 | MED | Scope Queue(2) while queue 1 still runs | fires when queue 2 is done | unit | — |
| 12 | HIGH | `ManualClock` zone with +1 h at the 2026-03-29 01:00 UTC step (Europe), window 02:00-03:00 | `contains` follows local time: closed before, open after; no panic in the skipped hour | unit | — |
| 13 | MED | Zone change (offset +0 to +9 h) while window 22:00-06:00 | open/closed follows the new wall time at once | unit | — |
| 14 | MED | `opened_between` over a 10-hour sleep that spans a window start, and one that spans none or only an end | true for the first; false for the others; scan capped at 8 days | unit | — |
| 15 | MED | Night window Mon 22:00-06:00 | Tuesday 05:59 open, 06:00 closed, Monday 05:00 closed; `from == to` is the whole day | unit | — |
| 16 | MED | `Grid::new` with 167 and 168 cells; `at` on Monday 00:30 and Sunday 23:30 | None for 167; first and last cell | unit | — |
| 17 | HIGH | `expand` with `{file}` = `/a b/c; rm -rf /` | one argument, unchanged; no shell run | unit | — |
| 18 | MED | `run` with `sleep 5`, timeout 1 s; with `echo hi`; with a missing program; with exit code 1 | timeout error naming seconds; Ok("hi\n"); "did not start"; "ended with" error | integration | — |
| 19 | HIGH | Fake `Power` that records calls: drive a `Fire(Shutdown)` through the caller | only the fake is called; `Logind` is never used in tests | unit | — |
| 20 | LOW | `Logind::can` on this PC (capabilities only, no perform) | Shutdown/Suspend answer without calling the methods; Quit and Run always true | by hand | — |
| 1 | HIGH | Queue with `paused`, add a task to it | task stays Queued, nothing downloads; unpause starts it | integration (testserver, `Config.clock` default) | pass |
| 2 | HIGH | Queue `max_active = 1`, three tasks, global max 4 | only one runs at a time, the others follow in order | integration | pass |
| 3 | HIGH | Queue schedule Mon 22:00-06:00 on a ManualClock at Mon 21:59, then advance 2 minutes | task starts within one look (~15 s real, or send a command to force choose) | integration | pass |
| 4 | HIGH | Running task, clock leaves the window | task goes back to Queued, not Failed; returns when the window opens | integration | pass |
| 5 | HIGH | Start by hand (`forced`) in a paused or closed queue | it runs | integration | pass |
| 6 | HIGH | Task B `after` A; A Running | B stays Queued; when A is Done, B starts | integration | pass |
| 7 | HIGH | `after` pointing at itself, at a chain that returns, at a removed task | first two give `Error::Cycle` and nothing is saved; the last is accepted and B isn't held | integration | pass |
| 8 | HIGH | `Watcher` with `even_failed = false`, one Done and one Failed | `Step::Blocked`, disarmed, never fires | unit | pass |
| 9 | HIGH | Same with `even_failed = true` | countdown starts, fires after the countdown | unit | pass |
| 10 | MED | Cancel during the countdown; a task of the scope starts again | `Idle` after cancel; a new running task resets the countdown | unit | pass |
| 11 | MED | Scope Queue(2) while queue 1 still runs | fires when queue 2 is done | unit | pass |
| 12 | HIGH | `ManualClock` zone with +1 h at the 2026-03-29 01:00 UTC step (Europe), window 02:00-03:00 | `contains` follows local time: closed before, open after; no panic in the skipped hour | unit | pass |
| 13 | MED | Zone change (offset +0 to +9 h) while window 22:00-06:00 | open/closed follows the new wall time at once | unit | pass |
| 14 | MED | `opened_between` over a 10-hour sleep that spans a window start, and one that spans none or only an end | true for the first; false for the others; scan capped at 8 days | unit | pass |
| 15 | MED | Night window Mon 22:00-06:00 | Tuesday 05:59 open, 06:00 closed, Monday 05:00 closed; `from == to` is the whole day | unit | pass |
| 16 | MED | `Grid::new` with 167 and 168 cells; `at` on Monday 00:30 and Sunday 23:30 | None for 167; first and last cell | unit | pass |
| 17 | HIGH | `expand` with `{file}` = `/a b/c; rm -rf /` | one argument, unchanged; no shell run | unit | pass |
| 18 | MED | `run` with `sleep 5`, timeout 1 s; with `echo hi`; with a missing program; with exit code 1 | timeout error naming seconds; Ok("hi\n"); "did not start"; "ended with" error | integration | pass |
| 19 | HIGH | Fake `Power` that records calls: drive a `Fire(Shutdown)` through the caller | only the fake is called; `Logind` is never used in tests | unit | not run: no fake Power driven through the app caller |
| 20 | LOW | `Logind::can` on this PC (capabilities only, no perform) | Shutdown/Suspend answer without calling the methods; Quit and Run always true | by hand | not run: by hand |
## Needs
`crates/testserver` on 127.0.0.1; a throwaway home; a `ManualClock` in `Config.clock`. Never call `Logind::perform` or `Inhibitor::take` for real in tests except by hand on check 20 (capabilities only).
@ -43,3 +43,6 @@ Risk: HIGH = data loss, security, crash, wrong result · MED = feature broken ·
- A closed or paused queue pushes running tasks back to Queued; a task running in a queue that gets paused is suspended, not paused.
- `pick` and `Candidate` got a field and a parameter; the unit tests in pick.rs were edited to match, not run.
- Fall-back hour: the window counts twice (documented); not covered by a check.
## Notes (S041)
- Run in `crates/core/tests/queues.rs` (1-7) and `control.rs` (8-18). Found and fixed: `Rule::fits` required extensions AND mime; now OR (rules unit test).

View file

@ -29,3 +29,6 @@ Run the app with a throwaway home. Doubts first.
15. While downloading, the system is kept awake (check inhibitor via loginctl); lock released when idle.
16. Idle with the sheet closed draws no frames.
17. Disabled actions (not possible here) are labelled.
## Results (S041)
1-17: not run: screen or by-hand checks, no harness written. Logic behind 8, 11, 14 (hours, zone, run) is covered by `crates/core/tests/control.rs` and `queues.rs` (S021 checks 3-4, 12-18, pass).

View file

@ -13,24 +13,24 @@ Nothing is wired into the app yet (S024). Reach it from a test: `Connector::star
## Checks
| # | Risk | Do this | Expect | How | Result |
|---|---|---|---|---|---|
| 1 | HIGH | Start on port 0; `ss -ltn` / `status()` | `On(p)`, bound on 127.0.0.1 only, nothing on 0.0.0.0 or :: | integration | — |
| 2 | HIGH | curl POST the fixture with `Content-Type: application/json` | 200 `{"accepted":1,"refused":[]}`; one `Arrival`: url, name `a.zip`, page `https://example.com/`, user agent `UA`, secret cookies `k=v`, `task_headers()` has User-Agent and Referer, no Cookie | integration | — |
| 3 | HIGH | `Host: evil.example:p`, `Host: 127.0.0.1:1`, two Host headers, no Host | 403 `host`, no Arrival, log entry Refused(Host) | integration | — |
| 4 | HIGH | Add `Origin: https://evil.example`, `Origin: null`, `Sec-Fetch-Site: cross-site`, `Sec-Fetch-Mode: cors` (each alone) | 403 `origin` | integration | — |
| 5 | HIGH | POST with `application/x-www-form-urlencoded`, `multipart/form-data`, `text/plain`, `application/json; charset=latin1` | 415 `content-type` | integration | — |
| 6 | HIGH | `OPTIONS /` with `Access-Control-Request-Method: POST`; also POST with that header | 405 `preflight`; no `Access-Control-*` header in any answer of checks 2–9 | integration | — |
| 7 | HIGH | Link headers `{"X-A":"1\r\nX-B: 2","Connection":"close","Range":"bytes=5-","Accept-Encoding":"gzip","If-None-Match":"x","Authorization":"Bearer t"}` | X-A, Connection, Range, Accept-Encoding, If-None-Match dropped (in `dropped`); Authorization only in `secret.headers`; user agent with `\n` dropped | unit | — |
| 8 | HIGH | Links `javascript:alert(1)`, `file:///etc/passwd`, `data:,x`, `http://`, a 9 KiB URL, `https://u:p@h/f` | first five refused (`scheme`/`invalid`), last accepted as `https://h/f` with the login in `secret` | unit | — |
| 9 | HIGH | Filename `../../.bashrc`, `a\u0000b`, 400 chars | made safe by `http::name::safe` (no slashes, no leading dot, capped) | unit | — |
| 10 | HIGH | `Incoming::task` with `Secrets::new(Bus::Off)` | task.secret is a `task:` name; `secrets.load` gives the cookies; task headers carry no secret (store accepts it) | unit | — |
| 11 | HIGH | Log after checks 2–8 | entries with time, what, outcome; no cookie value, login or query string appears in any `what` | integration | — |
| 12 | MED | GET `/` | 200 `{"name":"Medlar","version":...}`, not logged | integration | — |
| 13 | MED | List of 3 links, one bad; then a list of 1001; then `{}`; then `[]`; then `not json` | 200 accepted 2 refused index 1; 413 `too-many`; 422 `no-links`; 422; 400 `body` | integration | — |
| 14 | MED | Body 1 MiB + 1; `Transfer-Encoding: chunked`; head of 20 KiB; open and send nothing for 6 s | 413; 411; 413; 408 or closed | integration | — |
| 15 | MED | 40 requests at once from one loop | the first ≈30 answered normally, later ones 429 `busy` | integration | — |
| 16 | MED | Hold the port with another listener, start on it | `Taken { by: Some(test binary name) }`, `words()` names the port and the fix; free it: `On` within ~5 s | integration | — |
| 17 | MED | `set(false, p)`, then `set(true, q)` | port closed (connect refused), then open on q; status follows | integration | — |
| 18 | LOW | Sender of check 2 | `from.process` is `curl` (a process of this user) | integration | — |
| 1 | HIGH | Start on port 0; `ss -ltn` / `status()` | `On(p)`, bound on 127.0.0.1 only, nothing on 0.0.0.0 or :: | integration | pass |
| 2 | HIGH | curl POST the fixture with `Content-Type: application/json` | 200 `{"accepted":1,"refused":[]}`; one `Arrival`: url, name `a.zip`, page `https://example.com/`, user agent `UA`, secret cookies `k=v`, `task_headers()` has User-Agent and Referer, no Cookie | integration | pass |
| 3 | HIGH | `Host: evil.example:p`, `Host: 127.0.0.1:1`, two Host headers, no Host | 403 `host`, no Arrival, log entry Refused(Host) | integration | pass |
| 4 | HIGH | Add `Origin: https://evil.example`, `Origin: null`, `Sec-Fetch-Site: cross-site`, `Sec-Fetch-Mode: cors` (each alone) | 403 `origin` | integration | pass |
| 5 | HIGH | POST with `application/x-www-form-urlencoded`, `multipart/form-data`, `text/plain`, `application/json; charset=latin1` | 415 `content-type` | integration | pass |
| 6 | HIGH | `OPTIONS /` with `Access-Control-Request-Method: POST`; also POST with that header | 405 `preflight`; no `Access-Control-*` header in any answer of checks 2–9 | integration | pass |
| 7 | HIGH | Link headers `{"X-A":"1\r\nX-B: 2","Connection":"close","Range":"bytes=5-","Accept-Encoding":"gzip","If-None-Match":"x","Authorization":"Bearer t"}` | X-A, Connection, Range, Accept-Encoding, If-None-Match dropped (in `dropped`); Authorization only in `secret.headers`; user agent with `\n` dropped | unit | pass |
| 8 | HIGH | Links `javascript:alert(1)`, `file:///etc/passwd`, `data:,x`, `http://`, a 9 KiB URL, `https://u:p@h/f` | first five refused (`scheme`/`invalid`), last accepted as `https://h/f` with the login in `secret` | unit | pass |
| 9 | HIGH | Filename `../../.bashrc`, `a\u0000b`, 400 chars | made safe by `http::name::safe` (no slashes, no leading dot, capped) | unit | pass |
| 10 | HIGH | `Incoming::task` with `Secrets::new(Bus::Off)` | task.secret is a `task:` name; `secrets.load` gives the cookies; task headers carry no secret (store accepts it) | unit | pass |
| 11 | HIGH | Log after checks 2–8 | entries with time, what, outcome; no cookie value, login or query string appears in any `what` | integration | pass |
| 12 | MED | GET `/` | 200 `{"name":"Medlar","version":...}`, not logged | integration | pass |
| 13 | MED | List of 3 links, one bad; then a list of 1001; then `{}`; then `[]`; then `not json` | 200 accepted 2 refused index 1; 413 `too-many`; 422 `no-links`; 422; 400 `body` | integration | pass |
| 14 | MED | Body 1 MiB + 1; `Transfer-Encoding: chunked`; head of 20 KiB; open and send nothing for 6 s | 413; 411; 413; 408 or closed | integration | pass |
| 15 | MED | 40 requests at once from one loop | the first ≈30 answered normally, later ones 429 `busy` | integration | pass (40 requests sent in a loop; parallel ones beyond 16 connections are dropped silently, see Doubts) |
| 16 | MED | Hold the port with another listener, start on it | `Taken { by: Some(test binary name) }`, `words()` names the port and the fix; free it: `On` within ~5 s | integration | pass |
| 17 | MED | `set(false, p)`, then `set(true, q)` | port closed (connect refused), then open on q; status follows | integration | pass |
| 18 | LOW | Sender of check 2 | `from.process` is `curl` (a process of this user) | integration | not run: the sender is the test binary, not curl |
## Needs
Loopback only, ports chosen free (port 0) — never 15151 or 38151 or 17616 while the user's Medlar runs. curl for check 2. No network.
@ -43,3 +43,6 @@ Loopback only, ports chosen free (port 0) — never 15151 or 38151 or 17616 whil
- `peer::process` scans every `/proc/*/fd`: may be slow with many processes; it runs beside the read.
- `Body` is untagged: a known field of the wrong JSON type (for example `"headers": []`) refuses the whole body with `body`.
- The UI is not wired: S024 must call `Connector::start`/`set` from settings and show `status().words()`.
## Doubts found in S041
- More than 16 connections open at once are dropped without any answer (no 429); the 429 comes only from the rate gate (check 15 run in a loop).

View file

@ -14,22 +14,22 @@ Risk: HIGH = data loss, security, crash, wrong result · MED = feature broken ·
| # | Risk | Do this | Expect | How | Result |
|---|---|---|---|---|---|
| 1 | HIGH | `medlar:` link and `/x.metalink` through `of_arg`; `--show`, `medlar:nothing` | Request with literal text / list; the last two give none | unit | — |
| 2 | HIGH | Hidden run, throwaway home, POST one link to the port | Add dialog opens with the link filled in | by hand | — |
| 3 | HIGH | Same with `add_without_asking` off and a `medlar:` link on the socket | Dialog shown, never added silently | by hand | — |
| 4 | HIGH | Turn `add_without_asking` on, types `zip`, send a `.zip` and a `.iso` | zip added at once with a toast; iso opens the dialog | by hand | — |
| 5 | MED | `auto_ok` with sizes: min 10 MB, max 100 MB; sizes 5, 50, 500 MB and unknown | false, true, false, true | unit | — |
| 6 | MED | Send a list of 3 links in one POST | One dialog in batch mode | by hand | — |
| 7 | MED | Send 3 POSTs in a row | Dialogs come one after another; the window is raised once | by hand | — |
| 8 | HIGH | Paused download from the same URL with new token; send the link | Dialog offers "Continue" first with the verdict | by hand | — |
| 9 | HIGH | Task waiting on "open source page" (expired link); send a fresh link | Check runs, the task continues, toast says so, no dialog | by hand | — |
| 10 | HIGH | Same, but the fresh link leads to another file | Task stays, error toast with why | by hand | — |
| 11 | MED | Settings, Browser: switch off, change port, press Send a test link | State line follows; test opens the Add dialog; log shows the entry | by hand | — |
| 12 | HIGH | Start a second `medlar medlar:https://a.test/f` with the same home | It ends at once; the first window shows the Add dialog | by hand | — |
| 13 | MED | Kill the first with SIGKILL, start again | Starts normally (stale socket removed) | by hand | — |
| 14 | HIGH | Nacre with a throwaway home, Medlar on a spare port against testserver; click a download | It arrives and downloads; else replay Nacre's body with curl and say so | by hand | — |
| 15 | HIGH | Download, expire the link on testserver, send a fresh one | File completes identical (hash) | by hand | — |
| 16 | LOW | Port taken by another program | Page shows the plain-words fix | by hand | — |
| 1 | HIGH | `medlar:` link and `/x.metalink` through `of_arg`; `--show`, `medlar:nothing` | Request with literal text / list; the last two give none | unit | pass (unit `incoming::tests::arguments`) |
| 2 | HIGH | Hidden run, throwaway home, POST one link to the port | Add dialog opens with the link filled in | by hand | not run: by hand check, no harness written |
| 3 | HIGH | Same with `add_without_asking` off and a `medlar:` link on the socket | Dialog shown, never added silently | by hand | not run: by hand check, no harness written |
| 4 | HIGH | Turn `add_without_asking` on, types `zip`, send a `.zip` and a `.iso` | zip added at once with a toast; iso opens the dialog | by hand | not run: by hand check, no harness written |
| 5 | MED | `auto_ok` with sizes: min 10 MB, max 100 MB; sizes 5, 50, 500 MB and unknown | false, true, false, true | unit | not run: unit check, no harness written |
| 6 | MED | Send a list of 3 links in one POST | One dialog in batch mode | by hand | not run: by hand check, no harness written |
| 7 | MED | Send 3 POSTs in a row | Dialogs come one after another; the window is raised once | by hand | not run: by hand check, no harness written |
| 8 | HIGH | Paused download from the same URL with new token; send the link | Dialog offers "Continue" first with the verdict | by hand | not run: by hand check, no harness written |
| 9 | HIGH | Task waiting on "open source page" (expired link); send a fresh link | Check runs, the task continues, toast says so, no dialog | by hand | not run: by hand check, no harness written |
| 10 | HIGH | Same, but the fresh link leads to another file | Task stays, error toast with why | by hand | not run: by hand check, no harness written |
| 11 | MED | Settings, Browser: switch off, change port, press Send a test link | State line follows; test opens the Add dialog; log shows the entry | by hand | not run: by hand check, no harness written |
| 12 | HIGH | Start a second `medlar medlar:https://a.test/f` with the same home | It ends at once; the first window shows the Add dialog | by hand | not run: by hand check, no harness written |
| 13 | MED | Kill the first with SIGKILL, start again | Starts normally (stale socket removed) | by hand | not run: by hand check, no harness written |
| 14 | HIGH | Nacre with a throwaway home, Medlar on a spare port against testserver; click a download | It arrives and downloads; else replay Nacre's body with curl and say so | by hand | not run: by hand check, no harness written |
| 15 | HIGH | Download, expire the link on testserver, send a fresh one | File completes identical (hash) | by hand | not run: by hand check, no harness written |
| 16 | LOW | Port taken by another program | Page shows the plain-words fix | by hand | not run: by hand check, no harness written |
## Needs
Throwaway `MEDLAR_HOME` and `XDG_*`, `tools/hidden.sh`, `crates/testserver` for expiry, a spare port (not 15151, 38151), Nacre at `~/Projects/Nacre/target/release/nacre` with a throwaway home. Never touch `~/.abdm`.

View file

@ -26,7 +26,6 @@ description
done_all
download
download_done
note
drag_indicator
edit
error
@ -43,6 +42,7 @@ hourglass_empty
image
info
key
keyboard
keyboard_arrow_down
keyboard_arrow_up
label
@ -60,6 +60,8 @@ more_horiz
more_vert
movie
music_note
note
notifications
open_in_new
package_2
palette
@ -71,7 +73,6 @@ power_settings_new
priority_high
progress_activity
public
stacks
refresh
remove
replay
@ -80,11 +81,13 @@ schedule
search
security
select_all
send
settings
shield
slow_motion_video
sort
speed
stacks
stop
stop_circle
subtitles
@ -106,5 +109,3 @@ visibility_off
vpn_key
warning
wifi_off
notifications
keyboard