|
|
|
|
@ -504,3 +504,33 @@ func TestLazyMachineKeyGeneration(t *testing.T) { |
|
|
|
|
// hit panicOnUseTransport).
|
|
|
|
|
time.Sleep(500 * time.Millisecond) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestFileTargets(t *testing.T) { |
|
|
|
|
b := new(LocalBackend) |
|
|
|
|
_, err := b.FileTargets() |
|
|
|
|
if got, want := fmt.Sprint(err), "not connected"; got != want { |
|
|
|
|
t.Errorf("before connect: got %q; want %q", got, want) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
b.netMap = new(netmap.NetworkMap) |
|
|
|
|
_, err = b.FileTargets() |
|
|
|
|
if got, want := fmt.Sprint(err), "not connected"; got != want { |
|
|
|
|
t.Errorf("non-running netmap: got %q; want %q", got, want) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
b.state = ipn.Running |
|
|
|
|
_, err = b.FileTargets() |
|
|
|
|
if got, want := fmt.Sprint(err), "file sharing not enabled by Tailscale admin"; got != want { |
|
|
|
|
t.Errorf("without cap: got %q; want %q", got, want) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
b.capFileSharing = true |
|
|
|
|
got, err := b.FileTargets() |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatal(err) |
|
|
|
|
} |
|
|
|
|
if len(got) != 0 { |
|
|
|
|
t.Fatalf("unexpected %d peers", len(got)) |
|
|
|
|
} |
|
|
|
|
// (other cases handled by TestPeerAPIBase above)
|
|
|
|
|
} |
|
|
|
|
|