summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/modifiers_test.go
diff options
context:
space:
mode:
authorChris Koch <chrisko@google.com>2019-12-28 00:33:22 -0800
committerinsomniac <insomniacslk@users.noreply.github.com>2020-03-05 15:51:55 +0000
commit8d3e32a40580e3e227f64d9068f84b321e7921b2 (patch)
tree5419ea36fd39b6775f06f683ba0ad1b906d3341d /dhcpv6/modifiers_test.go
parent9e4750895995d4d3f4dd36d4fff26d7b3927a34b (diff)
dhcpv6: intro Getters for Options
Allow the Options type to have getters for each specific options, in order to avoid users having to cast options to their specific type. This commit introduces a getter for exactly one option: the ClientArchType. i.e. users can replace archTypes := msg.GetOneOption(OptionClientArchType).(*OptClientArchType) with archTypes := msg.Options.ArchTypes() Because a few message types and options embed options (normal message, relay message, IANA/IATA option) and each have a restricted set of options that can be used inside them, we'll introduce at least 3 or more Options subtypes: - MessageOptions - RelayOptions - IdentityOptions Perhaps others will join at a later time, such as VendorOptions or AddressOptions for the IAAddress options field. Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/modifiers_test.go')
-rw-r--r--dhcpv6/modifiers_test.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/dhcpv6/modifiers_test.go b/dhcpv6/modifiers_test.go
index dfef08c..ec8ff0b 100644
--- a/dhcpv6/modifiers_test.go
+++ b/dhcpv6/modifiers_test.go
@@ -60,8 +60,8 @@ func TestWithIANA(t *testing.T) {
PreferredLifetime: 3600,
ValidLifetime: 5200,
})(&d)
- require.Equal(t, 1, len(d.Options))
- require.Equal(t, OptionIANA, d.Options[0].Code())
+ require.Equal(t, 1, len(d.Options.Options))
+ require.Equal(t, OptionIANA, d.Options.Options[0].Code())
}
func TestWithDNS(t *testing.T) {
@@ -70,8 +70,8 @@ func TestWithDNS(t *testing.T) {
net.ParseIP("fe80::1"),
net.ParseIP("fe80::2"),
}...)(&d)
- require.Equal(t, 1, len(d.Options))
- dns := d.Options[0].(*OptDNSRecursiveNameServer)
+ require.Equal(t, 1, len(d.Options.Options))
+ dns := d.Options.Options[0].(*OptDNSRecursiveNameServer)
log.Printf("DNS %+v", dns)
require.Equal(t, OptionDNSRecursiveNameServer, dns.Code())
require.Equal(t, 2, len(dns.NameServers))
@@ -86,8 +86,8 @@ func TestWithDomainSearchList(t *testing.T) {
"slackware.it",
"dhcp.slackware.it",
}...)(&d)
- require.Equal(t, 1, len(d.Options))
- osl := d.Options[0].(*OptDomainSearchList)
+ require.Equal(t, 1, len(d.Options.Options))
+ osl := d.Options.Options[0].(*OptDomainSearchList)
require.Equal(t, OptionDomainSearchList, osl.Code())
require.NotNil(t, osl.DomainSearchList)
labels := osl.DomainSearchList.Labels