mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-02 14:32:26 +00:00
controlclient and ipn tests: supply --advertise-tags and --advertise-routes.
This helps validate the server's behaviour when these are present.
This commit is contained in:
parent
68a173bc24
commit
108237798d
@ -54,6 +54,23 @@ func TestClientsReusingKeys(t *testing.T) {
|
|||||||
hi := NewHostinfo()
|
hi := NewHostinfo()
|
||||||
hi.FrontendLogID = "go-test-only"
|
hi.FrontendLogID = "go-test-only"
|
||||||
hi.BackendLogID = "go-test-only"
|
hi.BackendLogID = "go-test-only"
|
||||||
|
|
||||||
|
// Let's test some nonempty extra hostinfo fields to make sure
|
||||||
|
// the server can handle them.
|
||||||
|
hi.RequestTags = []string{"tag:abc"}
|
||||||
|
cidr, err := wgcfg.ParseCIDR("1.2.3.4/24")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("ParseCIDR: %v", err)
|
||||||
|
}
|
||||||
|
hi.RoutableIPs = []wgcfg.CIDR{cidr}
|
||||||
|
hi.Services = []tailcfg.Service{
|
||||||
|
{
|
||||||
|
Proto: tailcfg.TCP,
|
||||||
|
Port: 1234,
|
||||||
|
Description: "Description",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
c1, err := NewDirect(Options{
|
c1, err := NewDirect(Options{
|
||||||
ServerURL: httpsrv.URL,
|
ServerURL: httpsrv.URL,
|
||||||
HTTPTestClient: httpsrv.Client(),
|
HTTPTestClient: httpsrv.Client(),
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tailscale/wireguard-go/tun/tuntest"
|
"github.com/tailscale/wireguard-go/tun/tuntest"
|
||||||
|
"github.com/tailscale/wireguard-go/wgcfg"
|
||||||
"tailscale.com/control/controlclient"
|
"tailscale.com/control/controlclient"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
"tailscale.com/tstest"
|
"tailscale.com/tstest"
|
||||||
@ -39,7 +40,7 @@ func TestIPN(t *testing.T) {
|
|||||||
tstest.FixLogs(t)
|
tstest.FixLogs(t)
|
||||||
defer tstest.UnfixLogs(t)
|
defer tstest.UnfixLogs(t)
|
||||||
|
|
||||||
// Turn off STUN for the test to make it hermitic.
|
// Turn off STUN for the test to make it hermetic.
|
||||||
// TODO(crawshaw): add a test that runs against a local STUN server.
|
// TODO(crawshaw): add a test that runs against a local STUN server.
|
||||||
magicsock.DisableSTUNForTesting = true
|
magicsock.DisableSTUNForTesting = true
|
||||||
defer func() { magicsock.DisableSTUNForTesting = false }()
|
defer func() { magicsock.DisableSTUNForTesting = false }()
|
||||||
@ -72,11 +73,11 @@ func TestIPN(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
n1 := newNode(t, "n1", https)
|
n1 := newNode(t, "n1", https, false)
|
||||||
defer n1.Backend.Shutdown()
|
defer n1.Backend.Shutdown()
|
||||||
n1.Backend.StartLoginInteractive()
|
n1.Backend.StartLoginInteractive()
|
||||||
|
|
||||||
n2 := newNode(t, "n2", https)
|
n2 := newNode(t, "n2", https, true)
|
||||||
defer n2.Backend.Shutdown()
|
defer n2.Backend.Shutdown()
|
||||||
n2.Backend.StartLoginInteractive()
|
n2.Backend.StartLoginInteractive()
|
||||||
|
|
||||||
@ -188,7 +189,7 @@ type testNode struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a new IPN node.
|
// Create a new IPN node.
|
||||||
func newNode(t *testing.T, prefix string, https *httptest.Server) testNode {
|
func newNode(t *testing.T, prefix string, https *httptest.Server, weirdPrefs bool) testNode {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
logfe := func(fmt string, args ...interface{}) {
|
logfe := func(fmt string, args ...interface{}) {
|
||||||
t.Logf(prefix+".e: "+fmt, args...)
|
t.Logf(prefix+".e: "+fmt, args...)
|
||||||
@ -221,6 +222,18 @@ func newNode(t *testing.T, prefix string, https *httptest.Server) testNode {
|
|||||||
prefs := NewPrefs()
|
prefs := NewPrefs()
|
||||||
prefs.ControlURL = https.URL
|
prefs.ControlURL = https.URL
|
||||||
prefs.Persist = &c
|
prefs.Persist = &c
|
||||||
|
|
||||||
|
if weirdPrefs {
|
||||||
|
// Let's test some nonempty extra prefs fields to make sure
|
||||||
|
// the server can handle them.
|
||||||
|
prefs.AdvertiseTags = []string{"tag:abc"}
|
||||||
|
cidr, err := wgcfg.ParseCIDR("1.2.3.4/24")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("ParseCIDR: %v", err)
|
||||||
|
}
|
||||||
|
prefs.AdvertiseRoutes = []wgcfg.CIDR{cidr}
|
||||||
|
}
|
||||||
|
|
||||||
n.Start(Options{
|
n.Start(Options{
|
||||||
FrontendLogID: prefix + "-f",
|
FrontendLogID: prefix + "-f",
|
||||||
Prefs: prefs,
|
Prefs: prefs,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user