mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-07 08:07:42 +00:00
net/tsaddr: add ChromeOS contains tests
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
parent
cf2ac2d123
commit
1e88050403
@ -4,7 +4,32 @@
|
|||||||
|
|
||||||
package tsaddr
|
package tsaddr
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"inet.af/netaddr"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestInCrostiniRange(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
ip netaddr.IP
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{netaddr.IPv4(192, 168, 0, 1), false},
|
||||||
|
{netaddr.IPv4(100, 101, 102, 103), false},
|
||||||
|
{netaddr.IPv4(100, 115, 92, 0), true},
|
||||||
|
{netaddr.IPv4(100, 115, 92, 5), true},
|
||||||
|
{netaddr.IPv4(100, 115, 92, 255), true},
|
||||||
|
{netaddr.IPv4(100, 115, 93, 40), true},
|
||||||
|
{netaddr.IPv4(100, 115, 94, 1), false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
if got := ChromeOSVMRange().Contains(test.ip); got != test.want {
|
||||||
|
t.Errorf("inCrostiniRange(%q) = %v, want %v", test.ip, got, test.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestChromeOSVMRange(t *testing.T) {
|
func TestChromeOSVMRange(t *testing.T) {
|
||||||
if got, want := ChromeOSVMRange().String(), "100.115.92.0/23"; got != want {
|
if got, want := ChromeOSVMRange().String(), "100.115.92.0/23"; got != want {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user