mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-24 02:31:18 -08:00
Allow TS_DEBUG_DISABLE_HOSTS_FILE_UPDATES to opt out of Windows hosts entries locally, using the existing tailscaled-env.txt configuration mechanism. Keep the control-plane node attribute authoritative and preserve upstream behavior when the local option is unset or false. Cover defaults, local opt-out, nil control knobs, and policy precedence with Windows tests. This change is limited to DNS configuration; no route changes or upstream route-fix cherry-pick are included. Updates tailscale/tailscale#14327 Signed-off-by: Caleb Crome <[email protected]>
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package dns
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"tailscale.com/control/controlknobs"
|
|
"tailscale.com/envknob"
|
|
)
|
|
|
|
func TestDisableHostsFileUpdatesLocal(t *testing.T) {
|
|
for _, tt := range []struct {
|
|
name, local string
|
|
policy, nilKnobs, want bool
|
|
}{
|
|
{"default", "", false, false, false},
|
|
{"local", "true", false, false, true},
|
|
{"localWithNilKnobs", "true", false, true, true},
|
|
{"defaultWithNilKnobs", "", false, true, false},
|
|
{"explicitFalse", "false", false, false, false},
|
|
{"policy", "", true, false, true},
|
|
{"localFalseCannotOverridePolicy", "false", true, false, true},
|
|
} {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
envknob.SetenvForTest(t, "TS_DEBUG_DISABLE_HOSTS_FILE_UPDATES", tt.local)
|
|
m := &windowsManager{}
|
|
if !tt.nilKnobs {
|
|
m.knobs = new(controlknobs.Knobs)
|
|
m.knobs.DisableHostsFileUpdates.Store(tt.policy)
|
|
}
|
|
if got := m.disableHostsFileUpdates(); got != tt.want {
|
|
t.Errorf("disableHostsFileUpdates() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|