2024-11-07 15:21:44 -08:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2025-09-30 11:54:16 -07:00
|
|
|
"maps"
|
|
|
|
|
"slices"
|
2025-09-08 12:09:29 -07:00
|
|
|
"strings"
|
2024-11-07 15:21:44 -08:00
|
|
|
"testing"
|
|
|
|
|
|
2025-09-30 11:54:16 -07:00
|
|
|
"tailscale.com/feature/featuretags"
|
2024-11-07 15:21:44 -08:00
|
|
|
"tailscale.com/tstest/deptest"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestOmitSSH(t *testing.T) {
|
|
|
|
|
const msg = "unexpected with ts_omit_ssh"
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
2025-09-16 18:11:28 -07:00
|
|
|
Tags: "ts_omit_ssh,ts_include_cli",
|
2024-11-07 15:21:44 -08:00
|
|
|
BadDeps: map[string]string{
|
2025-09-16 18:11:28 -07:00
|
|
|
"golang.org/x/crypto/ssh": msg,
|
2024-11-07 15:21:44 -08:00
|
|
|
"tailscale.com/ssh/tailssh": msg,
|
|
|
|
|
"tailscale.com/sessionrecording": msg,
|
|
|
|
|
"github.com/anmitsu/go-shlex": msg,
|
|
|
|
|
"github.com/creack/pty": msg,
|
|
|
|
|
"github.com/kr/fs": msg,
|
|
|
|
|
"github.com/pkg/sftp": msg,
|
|
|
|
|
"github.com/u-root/u-root/pkg/termios": msg,
|
|
|
|
|
"tempfork/gliderlabs/ssh": msg,
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
2025-09-02 16:50:10 -07:00
|
|
|
|
|
|
|
|
func TestOmitSyspolicy(t *testing.T) {
|
|
|
|
|
const msg = "unexpected syspolicy usage with ts_omit_syspolicy"
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: "ts_omit_syspolicy,ts_include_cli",
|
|
|
|
|
BadDeps: map[string]string{
|
|
|
|
|
"tailscale.com/util/syspolicy": msg,
|
|
|
|
|
"tailscale.com/util/syspolicy/setting": msg,
|
|
|
|
|
"tailscale.com/util/syspolicy/rsop": msg,
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
2025-09-08 12:09:29 -07:00
|
|
|
|
2025-09-23 17:07:48 -07:00
|
|
|
func TestOmitLocalClient(t *testing.T) {
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: "ts_omit_webclient,ts_omit_relayserver,ts_omit_oauthkey,ts_omit_acme",
|
|
|
|
|
BadDeps: map[string]string{
|
|
|
|
|
"tailscale.com/client/local": "unexpected",
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-08 12:09:29 -07:00
|
|
|
// Test that we can build a binary without reflect.MethodByName.
|
|
|
|
|
// See https://github.com/tailscale/tailscale/issues/17063
|
|
|
|
|
func TestOmitReflectThings(t *testing.T) {
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: "ts_include_cli,ts_omit_systray,ts_omit_debugeventbus,ts_omit_webclient",
|
|
|
|
|
BadDeps: map[string]string{
|
|
|
|
|
"text/template": "unexpected text/template usage",
|
|
|
|
|
"html/template": "unexpected text/template usage",
|
|
|
|
|
},
|
|
|
|
|
OnDep: func(dep string) {
|
|
|
|
|
if strings.Contains(dep, "systray") {
|
|
|
|
|
t.Errorf("unexpected systray dep %q", dep)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
2025-09-08 08:13:49 -07:00
|
|
|
|
|
|
|
|
func TestOmitDrive(t *testing.T) {
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: "ts_omit_drive,ts_include_cli",
|
|
|
|
|
OnDep: func(dep string) {
|
|
|
|
|
if strings.Contains(dep, "driveimpl") {
|
|
|
|
|
t.Errorf("unexpected dep with ts_omit_drive: %q", dep)
|
|
|
|
|
}
|
|
|
|
|
if strings.Contains(dep, "webdav") {
|
|
|
|
|
t.Errorf("unexpected dep with ts_omit_drive: %q", dep)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
2025-09-12 09:51:00 -07:00
|
|
|
|
2025-09-15 19:50:21 -07:00
|
|
|
func TestOmitPortmapper(t *testing.T) {
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: "ts_omit_portmapper,ts_include_cli,ts_omit_debugportmapper",
|
|
|
|
|
OnDep: func(dep string) {
|
|
|
|
|
if dep == "tailscale.com/net/portmapper" {
|
|
|
|
|
t.Errorf("unexpected dep with ts_omit_portmapper: %q", dep)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if strings.Contains(dep, "goupnp") || strings.Contains(dep, "/soap") ||
|
|
|
|
|
strings.Contains(dep, "internetgateway2") {
|
|
|
|
|
t.Errorf("unexpected dep with ts_omit_portmapper: %q", dep)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
2025-09-16 10:07:50 -07:00
|
|
|
|
|
|
|
|
func TestOmitACME(t *testing.T) {
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: "ts_omit_acme,ts_include_cli",
|
|
|
|
|
OnDep: func(dep string) {
|
|
|
|
|
if strings.Contains(dep, "/acme") {
|
|
|
|
|
t.Errorf("unexpected dep with ts_omit_acme: %q", dep)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
2025-09-19 12:31:44 -04:00
|
|
|
|
2025-09-23 15:49:49 -07:00
|
|
|
func TestOmitCaptivePortal(t *testing.T) {
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: "ts_omit_captiveportal,ts_include_cli",
|
|
|
|
|
OnDep: func(dep string) {
|
|
|
|
|
if strings.Contains(dep, "captive") {
|
|
|
|
|
t.Errorf("unexpected dep with ts_omit_captiveportal: %q", dep)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-19 12:31:44 -04:00
|
|
|
func TestOmitOAuthKey(t *testing.T) {
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: "ts_omit_oauthkey,ts_include_cli",
|
|
|
|
|
OnDep: func(dep string) {
|
|
|
|
|
if strings.HasPrefix(dep, "golang.org/x/oauth2") {
|
|
|
|
|
t.Errorf("unexpected dep with ts_omit_oauthkey: %q", dep)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
2025-09-17 09:44:50 -07:00
|
|
|
|
|
|
|
|
func TestOmitOutboundProxy(t *testing.T) {
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: "ts_omit_outboundproxy,ts_include_cli",
|
|
|
|
|
OnDep: func(dep string) {
|
|
|
|
|
if strings.Contains(dep, "socks5") || strings.Contains(dep, "proxymux") {
|
|
|
|
|
t.Errorf("unexpected dep with ts_omit_outboundproxy: %q", dep)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
2025-09-23 14:11:04 -07:00
|
|
|
|
|
|
|
|
func TestOmitDBus(t *testing.T) {
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: "ts_omit_networkmanager,ts_omit_dbus,ts_omit_resolved,ts_omit_systray,ts_omit_ssh,ts_include_cli",
|
|
|
|
|
OnDep: func(dep string) {
|
|
|
|
|
if strings.Contains(dep, "dbus") {
|
|
|
|
|
t.Errorf("unexpected DBus dep: %q", dep)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
2025-09-24 15:12:24 -07:00
|
|
|
|
2025-09-26 13:05:20 -07:00
|
|
|
func TestNetstack(t *testing.T) {
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: "ts_omit_gro,ts_omit_netstack,ts_omit_outboundproxy,ts_omit_serve,ts_omit_ssh,ts_omit_webclient,ts_omit_tap",
|
|
|
|
|
OnDep: func(dep string) {
|
|
|
|
|
if strings.Contains(dep, "gvisor") {
|
|
|
|
|
t.Errorf("unexpected gvisor dep: %q", dep)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-24 15:12:24 -07:00
|
|
|
func TestOmitPortlist(t *testing.T) {
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: "ts_omit_portlist,ts_include_cli",
|
|
|
|
|
OnDep: func(dep string) {
|
|
|
|
|
if strings.Contains(dep, "portlist") {
|
|
|
|
|
t.Errorf("unexpected dep: %q", dep)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
2025-09-25 13:19:11 -07:00
|
|
|
|
|
|
|
|
func TestOmitGRO(t *testing.T) {
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: "ts_omit_gro,ts_include_cli",
|
|
|
|
|
BadDeps: map[string]string{
|
|
|
|
|
"gvisor.dev/gvisor/pkg/tcpip/stack/gro": "unexpected dep with ts_omit_gro",
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
2025-09-30 09:12:42 -07:00
|
|
|
|
|
|
|
|
func TestOmitUseProxy(t *testing.T) {
|
|
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: "ts_omit_useproxy,ts_include_cli",
|
|
|
|
|
OnDep: func(dep string) {
|
|
|
|
|
if strings.Contains(dep, "tshttproxy") {
|
|
|
|
|
t.Errorf("unexpected dep: %q", dep)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
2025-09-30 11:54:16 -07:00
|
|
|
|
|
|
|
|
func minTags() string {
|
|
|
|
|
var tags []string
|
|
|
|
|
for _, f := range slices.Sorted(maps.Keys(featuretags.Features)) {
|
|
|
|
|
if f.IsOmittable() {
|
|
|
|
|
tags = append(tags, f.OmitTag())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return strings.Join(tags, ",")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestMinTailscaledNoCLI(t *testing.T) {
|
2025-09-30 14:47:40 -07:00
|
|
|
badSubstrs := []string{
|
|
|
|
|
"cbor",
|
|
|
|
|
"regexp",
|
|
|
|
|
"golang.org/x/net/proxy",
|
|
|
|
|
"internal/socks",
|
|
|
|
|
"github.com/tailscale/peercred",
|
2025-10-04 11:43:17 -07:00
|
|
|
"tailscale.com/types/netlogtype",
|
2025-10-04 17:40:09 -07:00
|
|
|
"deephash",
|
|
|
|
|
"util/hashx",
|
2025-09-30 14:47:40 -07:00
|
|
|
}
|
2025-09-30 11:54:16 -07:00
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: minTags(),
|
|
|
|
|
OnDep: func(dep string) {
|
2025-09-30 14:47:40 -07:00
|
|
|
for _, bad := range badSubstrs {
|
|
|
|
|
if strings.Contains(dep, bad) {
|
|
|
|
|
t.Errorf("unexpected dep: %q", dep)
|
|
|
|
|
}
|
2025-09-30 11:54:16 -07:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}.Check(t)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestMinTailscaledWithCLI(t *testing.T) {
|
2025-09-30 12:46:43 -07:00
|
|
|
badSubstrs := []string{
|
|
|
|
|
"cbor",
|
|
|
|
|
"hujson",
|
2025-09-30 13:31:38 -07:00
|
|
|
"pprof",
|
2025-09-30 19:47:50 -07:00
|
|
|
"multierr", // https://github.com/tailscale/tailscale/pull/17379
|
2025-10-06 12:02:16 -07:00
|
|
|
"tailscale.com/metrics",
|
|
|
|
|
"tailscale.com/tsweb/varz",
|
|
|
|
|
"dirwalk",
|
2025-10-04 17:40:09 -07:00
|
|
|
"deephash",
|
|
|
|
|
"util/hashx",
|
2025-09-30 12:46:43 -07:00
|
|
|
}
|
2025-09-30 11:54:16 -07:00
|
|
|
deptest.DepChecker{
|
|
|
|
|
GOOS: "linux",
|
|
|
|
|
GOARCH: "amd64",
|
|
|
|
|
Tags: minTags() + ",ts_include_cli",
|
|
|
|
|
OnDep: func(dep string) {
|
2025-09-30 12:46:43 -07:00
|
|
|
for _, bad := range badSubstrs {
|
|
|
|
|
if strings.Contains(dep, bad) {
|
|
|
|
|
t.Errorf("unexpected dep: %q", dep)
|
|
|
|
|
}
|
2025-09-30 11:54:16 -07:00
|
|
|
}
|
|
|
|
|
},
|
2025-10-01 08:53:48 -07:00
|
|
|
BadDeps: map[string]string{
|
2025-10-06 22:08:38 -07:00
|
|
|
"golang.org/x/net/http2": "unexpected x/net/http2 dep; tailscale/tailscale#17305",
|
|
|
|
|
"expvar": "unexpected expvar dep",
|
|
|
|
|
"github.com/mdlayher/genetlink": "unexpected genetlink dep",
|
2025-10-01 08:53:48 -07:00
|
|
|
},
|
2025-09-30 11:54:16 -07:00
|
|
|
}.Check(t)
|
|
|
|
|
}
|