f-28: fix: dhcp do not emit local default route

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-05-18 22:19:00 +02:00
commit 2504b435a3
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
4 changed files with 29 additions and 13 deletions

View file

@ -52,10 +52,11 @@ func newConf(t *testing.T, cidr string) Config {
t.Helper()
_, network, _ := net.ParseCIDR(cidr)
return Config{
Network: network,
Gateway: net.ParseIP("192.168.1.1").To4(),
Name: "test",
ConfDir: t.TempDir(),
Network: network,
Gateway: net.ParseIP("192.168.1.1").To4(),
DefaultRoute: true,
Name: "test",
ConfDir: t.TempDir(),
}
}
@ -94,6 +95,17 @@ func TestGenerateConfig_ContainsGateway(t *testing.T) {
}
}
func TestGenerateConfig_NoDefaultRoute(t *testing.T) {
conf := newConf(t, "192.168.1.0/29")
conf.DefaultRoute = false
path, _, _ := GenerateConfig(conf)
content, _ := os.ReadFile(path)
if strings.Contains(string(content), "dhcp-option=3,") {
t.Errorf("dhcp-option=3 présente alors que DefaultRoute=false :\n%s", content)
}
}
func TestGenerateConfig_ContainsDhcpRange(t *testing.T) {
_, network, _ := net.ParseCIDR("10.10.0.0/24")
conf := Config{