mirror of
https://github.com/tailscale/tailscale.git
synced 2026-12-01 14:12:32 -08:00
The Windowed UI depends on the Windows App Runtime, which cannot be installed unless app sideloading or Developer Mode is enabled. Sideloading is disabled by default on Windows builds older than 19041, and can be disabled by the user or by policy on newer ones. Add winutil.GetSideloadingState to read the settings, log the result when tailscaled starts, and add gauges for sideloading being disabled by policy, by the user or by default. Builds older than 17763 cannot run the Windows App Runtime at all, so they are reported as unsupported and do not count towards any of the gauges. Updates tailscale/corp#52316 Signed-off-by: Nick Khyl <[email protected]>
47 lines
2.5 KiB
Go
47 lines
2.5 KiB
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package winutil
|
|
|
|
import "testing"
|
|
|
|
func TestSideloadingStatus(t *testing.T) {
|
|
const (
|
|
unsupportedBuild = 17134 // Windows 10 1803
|
|
minBuild = 17763 // Windows 10 1809
|
|
oldBuild = 18363 // Windows 10 1909
|
|
newBuild = 19041 // Windows 10 2004
|
|
)
|
|
on, off := new(uint32(1)), new(uint32(0))
|
|
|
|
tests := []struct {
|
|
name string
|
|
state SideloadingState
|
|
want SideloadingStatus
|
|
}{
|
|
{"new-build-default", SideloadingState{Build: newBuild}, SideloadingEnabled},
|
|
{"unsupported-build", SideloadingState{Build: unsupportedBuild}, SideloadingUnsupported},
|
|
{"unsupported-build-local-on", SideloadingState{Build: unsupportedBuild, LocalAllowAllTrustedApps: on}, SideloadingUnsupported},
|
|
{"unsupported-build-dev-mode", SideloadingState{Build: unsupportedBuild, LocalDevMode: on}, SideloadingUnsupported},
|
|
{"min-build-default", SideloadingState{Build: minBuild}, SideloadingDisabledByDefault},
|
|
{"old-build-default", SideloadingState{Build: oldBuild}, SideloadingDisabledByDefault},
|
|
{"old-build-local-on", SideloadingState{Build: oldBuild, LocalAllowAllTrustedApps: on}, SideloadingEnabled},
|
|
{"old-build-policy-on", SideloadingState{Build: oldBuild, PolicyAllowAllTrustedApps: on}, SideloadingEnabled},
|
|
{"old-build-dev-mode", SideloadingState{Build: oldBuild, LocalDevMode: on}, SideloadingEnabled},
|
|
{"new-build-local-off", SideloadingState{Build: newBuild, LocalAllowAllTrustedApps: off}, SideloadingDisabledByUser},
|
|
{"new-build-policy-off", SideloadingState{Build: newBuild, PolicyAllowAllTrustedApps: off}, SideloadingDisabledByPolicy},
|
|
{"policy-off-overrides-local-on", SideloadingState{Build: newBuild, PolicyAllowAllTrustedApps: off, LocalAllowAllTrustedApps: on}, SideloadingDisabledByPolicy},
|
|
{"policy-on-overrides-local-off", SideloadingState{Build: oldBuild, PolicyAllowAllTrustedApps: on, LocalAllowAllTrustedApps: off}, SideloadingEnabled},
|
|
{"dev-mode-overrides-policy-off", SideloadingState{Build: newBuild, PolicyAllowAllTrustedApps: off, LocalDevMode: on}, SideloadingEnabled},
|
|
{"policy-dev-mode-off-overrides-local-dev-mode", SideloadingState{Build: oldBuild, PolicyDevMode: off, LocalDevMode: on}, SideloadingDisabledByDefault},
|
|
{"dev-mode-off-local-off", SideloadingState{Build: newBuild, LocalDevMode: off, LocalAllowAllTrustedApps: off}, SideloadingDisabledByUser},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := tt.state.Status(); got != tt.want {
|
|
t.Errorf("Status() = %q; want %q", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|