diff options
author | Chris Koch <chrisko@google.com> | 2019-12-28 03:39:31 -0800 |
---|---|---|
committer | Chris K <c@chrisko.ch> | 2020-03-09 15:38:59 -0700 |
commit | 94e5923c9c44b0e829d793508e6772e6a96feb47 (patch) | |
tree | caca593a883f537a376682aa90312123b929a214 /dhcpv6/option_remoteid_test.go | |
parent | a3af88f6782eba884ef5216b987bf4e2a96ff033 (diff) |
v6: add RemoteID getter to RelayOptions
Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/option_remoteid_test.go')
-rw-r--r-- | dhcpv6/option_remoteid_test.go | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/dhcpv6/option_remoteid_test.go b/dhcpv6/option_remoteid_test.go index b8b90f4..5c1ee52 100644 --- a/dhcpv6/option_remoteid_test.go +++ b/dhcpv6/option_remoteid_test.go @@ -7,27 +7,27 @@ import ( "github.com/stretchr/testify/require" ) -func TestOptRemoteId(t *testing.T) { +func TestOptRemoteID(t *testing.T) { expected := []byte{0xaa, 0xbb, 0xcc, 0xdd} remoteId := []byte("DSLAM01 eth2/1/01/21") expected = append(expected, remoteId...) - opt, err := ParseOptRemoteId(expected) + opt, err := ParseOptRemoteID(expected) if err != nil { t.Fatal(err) } - if en := opt.EnterpriseNumber(); en != 0xaabbccdd { + if en := opt.EnterpriseNumber; en != 0xaabbccdd { t.Fatalf("Invalid Enterprise Number. Expected 0xaabbccdd, got %v", en) } - if rid := opt.RemoteID(); !bytes.Equal(rid, remoteId) { + if rid := opt.RemoteID; !bytes.Equal(rid, remoteId) { t.Fatalf("Invalid Remote ID. Expected %v, got %v", expected, rid) } } -func TestOptRemoteIdToBytes(t *testing.T) { +func TestOptRemoteIDToBytes(t *testing.T) { remoteId := []byte("DSLAM01 eth2/1/01/21") expected := append([]byte{0, 0, 0, 0}, remoteId...) - opt := OptRemoteId{ - remoteId: remoteId, + opt := OptRemoteID{ + RemoteID: remoteId, } toBytes := opt.ToBytes() if !bytes.Equal(toBytes, expected) { @@ -35,41 +35,30 @@ func TestOptRemoteIdToBytes(t *testing.T) { } } -func TestOptRemoteIdSet(t *testing.T) { - enterpriseNumber := uint32(12345) - remoteID := []byte("DSLAM01 eth2/1/01/21") - opt := OptRemoteId{} - opt.SetEnterpriseNumber(enterpriseNumber) - opt.SetRemoteID(remoteID) - - require.Equal(t, uint32(12345), opt.EnterpriseNumber()) - require.Equal(t, []byte("DSLAM01 eth2/1/01/21"), opt.RemoteID()) -} - -func TestOptRemoteIdParseOptRemoteIdTooShort(t *testing.T) { +func TestOptRemoteIDParseOptRemoteIDTooShort(t *testing.T) { buf := []byte{0xaa, 0xbb, 0xcc} - _, err := ParseOptRemoteId(buf) + _, err := ParseOptRemoteID(buf) require.Error(t, err, "A short option should return an error") } -func TestOptRemoteIdString(t *testing.T) { +func TestOptRemoteIDString(t *testing.T) { buf := []byte{0xaa, 0xbb, 0xcc, 0xdd} remoteId := []byte("Test1234") buf = append(buf, remoteId...) - opt, err := ParseOptRemoteId(buf) + opt, err := ParseOptRemoteID(buf) require.NoError(t, err) str := opt.String() require.Contains( t, str, - "enterprisenum=2864434397", + "EnterpriseNumber 2864434397", "String() should contain the enterprisenum", ) require.Contains( t, str, - "remoteid=[84 101 115 116 49 50 51 52]", + "RemoteID [84 101 115 116 49 50 51 52]", "String() should contain the remoteid bytes", ) } |