controlclient and ipn tests: supply --advertise-tags and --advertise-routes.
This helps validate the server's behaviour when these are present.reviewable/pr352/r1
parent
68a173bc24
commit
108237798d
|
@ -54,6 +54,23 @@ func TestClientsReusingKeys(t *testing.T) {
|
|||
hi := NewHostinfo()
|
||||
hi.FrontendLogID = "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{
|
||||
ServerURL: httpsrv.URL,
|
||||
HTTPTestClient: httpsrv.Client(),
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/tailscale/wireguard-go/tun/tuntest"
|
||||
"github.com/tailscale/wireguard-go/wgcfg"
|
||||
"tailscale.com/control/controlclient"
|
||||
"tailscale.com/tailcfg"
|
||||
"tailscale.com/tstest"
|
||||
|
@ -39,7 +40,7 @@ func TestIPN(t *testing.T) {
|
|||
tstest.FixLogs(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.
|
||||
magicsock.DisableSTUNForTesting = true
|
||||
defer func() { magicsock.DisableSTUNForTesting = false }()
|
||||
|
@ -72,11 +73,11 @@ func TestIPN(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
n1 := newNode(t, "n1", https)
|
||||
n1 := newNode(t, "n1", https, false)
|
||||
defer n1.Backend.Shutdown()
|
||||
n1.Backend.StartLoginInteractive()
|
||||
|
||||
n2 := newNode(t, "n2", https)
|
||||
n2 := newNode(t, "n2", https, true)
|
||||
defer n2.Backend.Shutdown()
|
||||
n2.Backend.StartLoginInteractive()
|
||||
|
||||
|
@ -188,7 +189,7 @@ type testNode struct {
|
|||
}
|
||||
|
||||
// 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()
|
||||
logfe := func(fmt string, args ...interface{}) {
|
||||
t.Logf(prefix+".e: "+fmt, args...)
|
||||
|
@ -221,6 +222,18 @@ func newNode(t *testing.T, prefix string, https *httptest.Server) testNode {
|
|||
prefs := NewPrefs()
|
||||
prefs.ControlURL = https.URL
|
||||
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{
|
||||
FrontendLogID: prefix + "-f",
|
||||
Prefs: prefs,
|
||||
|
|
Loading…
Reference in New Issue