calculated_remote_test.go 552 B

123456789101112131415161718192021222324252627
  1. package nebula
  2. import (
  3. "net"
  4. "testing"
  5. "github.com/slackhq/nebula/iputil"
  6. "github.com/stretchr/testify/assert"
  7. "github.com/stretchr/testify/require"
  8. )
  9. func TestCalculatedRemoteApply(t *testing.T) {
  10. _, ipNet, err := net.ParseCIDR("192.168.1.0/24")
  11. require.NoError(t, err)
  12. c, err := newCalculatedRemote(ipNet, 4242)
  13. require.NoError(t, err)
  14. input := iputil.Ip2VpnIp([]byte{10, 0, 10, 182})
  15. expected := &Ip4AndPort{
  16. Ip: uint32(iputil.Ip2VpnIp([]byte{192, 168, 1, 182})),
  17. Port: 4242,
  18. }
  19. assert.Equal(t, expected, c.Apply(input))
  20. }