types/config, types/node: model default-auto-update from auto_update.enabled

Tailscale stamps tailcfg.NodeAttrDefaultAutoUpdate on every node's
CapMap with a JSON bool reflecting the tailnet-wide auto-update
default. Headscale grows an auto_update.enabled config option and
emits the cap accordingly from TailNode -- the cap leaves the
unmodelledTailnetStateCaps strip list and is compared in full by the
nodeAttrs compat suite.

testNodeAttrsSuccess drives cfg.AutoUpdate.Enabled from
tf.Input.Tailnet.Settings.DevicesAutoUpdatesOn so each capture's
expected emission matches the SaaS state it was taken under. Two
captures cover both branches:

  - nodeattrs-tailnet-devices-auto-updates-on  -> [true]
  - nodeattrs-tailnet-devices-auto-updates-off -> [false]

The Tailscale v2 TailnetSettings API does not expose the Send Files
toggle, so the compat suite cannot vary cfg.Taildrop.Enabled per
capture. TestTaildropDisabledWithholdsFileSharingCap covers the off
path directly in servertest.
This commit is contained in:
Kristoffer Dalby 2026-05-11 16:28:09 +00:00
parent 408f4022e4
commit 64d13f77e8
10 changed files with 9519 additions and 854 deletions

View file

@ -165,13 +165,12 @@ func TestNodeAttrsRevokesWhenRemoved(t *testing.T) {
})
}
// TestNodeAttrsBaselineCapsAlwaysOn verifies that the SaaS-baseline caps
// (Admin, SSH, FileSharing) are emitted on every node regardless of
// whether the policy mentions them. Tailscale SaaS emits these
// unconditionally for default tailnet settings; headscale matches that
// shape. Taildrive (drive:share / drive:access) is policy-driven per
// Tailscale's docs and is verified through TestNodeAttrsAddsToBaseline
// and the integration TestGrantCapDrive flow.
// TestNodeAttrsBaselineCapsAlwaysOn verifies that the baseline caps
// (Admin, SSH, FileSharing, DefaultAutoUpdate) are emitted on every
// node regardless of whether the policy mentions them. Taildrive
// (drive:share / drive:access) is policy-driven and is verified
// through TestNodeAttrsAddsToBaseline and the integration
// TestGrantCapDrive flow.
func TestNodeAttrsBaselineCapsAlwaysOn(t *testing.T) {
t.Parallel()
@ -189,6 +188,7 @@ func TestNodeAttrsBaselineCapsAlwaysOn(t *testing.T) {
tailcfg.CapabilityAdmin,
tailcfg.CapabilitySSH,
tailcfg.CapabilityFileSharing,
tailcfg.NodeAttrDefaultAutoUpdate,
} {
if !hasCap(nm, w) {
return false
@ -199,6 +199,30 @@ func TestNodeAttrsBaselineCapsAlwaysOn(t *testing.T) {
})
}
// TestTaildropDisabledWithholdsFileSharingCap asserts the off path of
// the Taildrop config gate. The Tailscale v2 API does not expose the
// equivalent tailnet setting, so the nodeAttrs compat suite cannot
// vary it; this test covers the headscale side directly.
func TestTaildropDisabledWithholdsFileSharingCap(t *testing.T) {
t.Parallel()
srv := servertest.NewServer(t, servertest.WithTaildropEnabled(false))
user := srv.CreateUser(t, "taildrop-off-user")
c := servertest.NewClient(t, srv, "taildrop-off-node", servertest.WithUser(user))
c.WaitForCondition(t, "file-sharing absent when taildrop disabled",
10*time.Second,
func(nm *netmap.NetworkMap) bool {
if nm == nil || !nm.SelfNode.Valid() {
return false
}
return !hasCap(nm, tailcfg.CapabilityFileSharing) &&
hasCap(nm, tailcfg.CapabilityAdmin) &&
hasCap(nm, tailcfg.CapabilitySSH)
})
}
// TestNodeAttrsAddsToBaseline verifies that policy nodeAttrs caps land on
// nodes alongside the always-on baseline. The baseline caps remain
// regardless of policy contents.