[roads] rustfmt the QA tests and the fuzz targets (no change in behaviour)

This commit is contained in:
2026-11-25 08:16:24 +01:00
parent d5917e7aab
commit 7087b06e24
4 changed files with 114 additions and 35 deletions
+43 -13
View File
@@ -96,7 +96,10 @@ fn f02_going_direct_never_overlaps_what_the_tunnel_carries() {
#[ignore = "QA F-03 (major): an invalid kill-switch road fails open"]
fn f03_a_kill_switch_whose_exit_goes_away_fails_closed() {
let parts = Parts::home().edit_devices(|d| {
d.replace(r#""address": "100.96.0.2", "exit": true,"#, r#""address": "100.96.0.2","#)
d.replace(
r#""address": "100.96.0.2", "exit": true,"#,
r#""address": "100.96.0.2","#,
)
});
let c = parts.compile();
assert!(c.has_plans());
@@ -118,7 +121,8 @@ fn f03_a_kill_switch_whose_exit_goes_away_fails_closed() {
#[test]
#[ignore = "QA F-04 (major): one dangling owner means no plans for anybody"]
fn f04_deleting_a_person_revokes_them_and_nobody_else() {
let parts = Parts::home().edit_directory(|d| d.replace(r#" { "id": "petr", "name": "Petr" },"#, ""));
let parts =
Parts::home().edit_directory(|d| d.replace(r#" { "id": "petr", "name": "Petr" },"#, ""));
let c = parts.compile();
assert!(
c.has_plans(),
@@ -126,7 +130,10 @@ fn f04_deleting_a_person_revokes_them_and_nobody_else() {
c.errors().map(|p| p.to_string()).collect::<Vec<_>>()
);
assert!(c.plans[&key(7)].exit.is_none(), "petr-phone kept its exit");
assert!(c.plans[&key(3)].peers.iter().any(|p| p.key == key(2)), "jana kept hers");
assert!(
c.plans[&key(3)].peers.iter().any(|p| p.key == key(2)),
"jana kept hers"
);
}
/// F-05. A custom road on a classic device is carried as `classic: false` unless the road says otherwise, so the
@@ -135,10 +142,15 @@ fn f04_deleting_a_person_revokes_them_and_nobody_else() {
#[ignore = "QA F-05 (minor): plan.custom takes `classic` from the road, not from the device"]
fn f05_a_custom_block_on_a_classic_device_is_labelled_classic() {
let router = key(5);
let text = Parts::home().road_text("x1d7qa").replace("classic: true\n", "");
let text = Parts::home()
.road_text("x1d7qa")
.replace("classic: true\n", "");
let parts = Parts::home().replace_road("x1d7qa", &text);
let c = parts.compile();
let refused = c.problems.iter().any(|p| p.path.contains("x1d7qa") && p.is_error());
let refused = c
.problems
.iter()
.any(|p| p.path.contains("x1d7qa") && p.is_error());
let custom = &c.plans[&router].custom;
assert!(
refused || custom.iter().all(|x| x.classic),
@@ -154,7 +166,10 @@ fn f05_a_custom_block_on_a_classic_device_is_labelled_classic() {
fn f06_a_road_across_address_families_is_reported() {
let parts = with(
Parts::home().edit_devices(|d| {
d.replace(r#""routes": ["192.168.100.0/24"]"#, r#""routes": ["192.168.100.0/24", "fd00:1::/64"]"#)
d.replace(
r#""routes": ["192.168.100.0/24"]"#,
r#""routes": ["192.168.100.0/24", "fd00:1::/64"]"#,
)
}),
road(
"f06aaa",
@@ -167,12 +182,19 @@ fn f06_a_road_across_address_families_is_reported() {
),
);
let c = parts.compile();
let mixed = c.plans.values().flat_map(|p| p.firewall.rules.iter()).any(|r| match r.dst {
Dst::Net(n) => n.inner().addr().is_ipv4() != r.src.inner().addr().is_ipv4(),
Dst::Internet => false,
});
let mixed = c
.plans
.values()
.flat_map(|p| p.firewall.rules.iter())
.any(|r| match r.dst {
Dst::Net(n) => n.inner().addr().is_ipv4() != r.src.inner().addr().is_ipv4(),
Dst::Internet => false,
});
let reported = c.problems.iter().any(|p| p.path.contains("f06aaa"));
assert!(reported || !mixed, "an IPv4 source to an IPv6 destination, silently");
assert!(
reported || !mixed,
"an IPv4 source to an IPv6 destination, silently"
);
}
/// F-07. A store folder without `roads/` compiles to plans with no access and no problem at all, so pointing
@@ -181,8 +203,16 @@ fn f06_a_road_across_address_families_is_reported() {
#[ignore = "QA F-07 (minor): a missing roads/ folder is not reported"]
fn f07_a_missing_roads_folder_is_reported() {
let dir = tempfile::tempdir().unwrap();
std::fs::copy(common::home_dir().join("directory.json"), dir.path().join("directory.json")).unwrap();
std::fs::copy(common::home_dir().join("devices.json"), dir.path().join("devices.json")).unwrap();
std::fs::copy(
common::home_dir().join("directory.json"),
dir.path().join("directory.json"),
)
.unwrap();
std::fs::copy(
common::home_dir().join("devices.json"),
dir.path().join("devices.json"),
)
.unwrap();
let store = Store::load_dir(dir.path()).unwrap();
let c = compile(&store, common::now());
assert!(