File: calculated_remote_test.go

package info (click to toggle)
nebula 1.9.3%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,772 kB
  • sloc: makefile: 183; sh: 100
file content (27 lines) | stat: -rw-r--r-- 552 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package nebula

import (
	"net"
	"testing"

	"github.com/slackhq/nebula/iputil"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

func TestCalculatedRemoteApply(t *testing.T) {
	_, ipNet, err := net.ParseCIDR("192.168.1.0/24")
	require.NoError(t, err)

	c, err := newCalculatedRemote(ipNet, 4242)
	require.NoError(t, err)

	input := iputil.Ip2VpnIp([]byte{10, 0, 10, 182})

	expected := &Ip4AndPort{
		Ip:   uint32(iputil.Ip2VpnIp([]byte{192, 168, 1, 182})),
		Port: 4242,
	}

	assert.Equal(t, expected, c.Apply(input))
}