systemd-resolved: test that a changed list replaces the old one on the link (issue 960)

R2's acceptance criteria name this case directly: the file's list changes
while the default-route link stays the same, and the guard gives the new
names to that same link without moving them first.

Builds: design 08 sign-in-page §7, §9
This commit is contained in:
jochen
2026-11-24 21:34:42 +01:00
parent 0c2a95aacd
commit 691ad760d3
@@ -337,6 +337,34 @@ func TestUplinkNamesMoveWithTheDefaultRoute(t *testing.T) {
}
}
// A changed list replaces the old one on the link, the route itself staying put (design 08 sign-in-page §9).
func TestAChangedListReplacesTheOldOneOnTheLink(t *testing.T) {
g, _, f, r := aGuardedMachineWithLinks(t, "wlan0")
f.dns = "Link 2 (wlan0): 192.168.1.1\n"
f.domain = "Link 2 (wlan0): lan\n"
f.ip = "default via 10.0.0.1 dev wlan0 metric 100\n"
if err := os.WriteFile(r.UplinkNamesFile, []byte("check.example\n"), 0o644); err != nil {
t.Fatal(err)
}
g.KeepUplinkNames(context.Background())
if len(f.changed) != 1 || strings.Join(f.changed[0], " ") != "resolvectl domain wlan0 lan ~check.example" {
t.Fatalf("the first list was given as %v", f.changed)
}
// resolved now holds it; the file's list changes, the link stays the same.
f.domain = "Link 2 (wlan0): lan ~check.example\n"
f.changed = nil
if err := os.WriteFile(r.UplinkNamesFile, []byte("other.example\n"), 0o644); err != nil {
t.Fatal(err)
}
g.KeepUplinkNames(context.Background())
if len(f.changed) != 1 || strings.Join(f.changed[0], " ") != "resolvectl domain wlan0 lan ~other.example" {
t.Errorf("the changed list was given as %v, want the old name replaced on the same link", f.changed)
}
if g.applied.Link != "wlan0" || strings.Join(g.applied.Names, ",") != "other.example" {
t.Errorf("applied is %+v", g.applied)
}
}
// A guard restarted with an applied file takes the uplink's names off the link it names, never inferring
// which (design 08 sign-in-page §8, §9; R-6).
func TestARestartedGuardTakesTheUplinkNamesOffTheLinkItNames(t *testing.T) {