summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/dhcpv4_test.go
diff options
context:
space:
mode:
authorDennis Marttinen <twelho@welho.tech>2023-03-27 01:00:58 +0300
committerDennis Marttinen <twelho@welho.tech>2023-03-27 01:04:10 +0300
commit94cdde992d5661bda1c88769d0a4319f3037c81e (patch)
tree8c2920c59b254c4627ef0cf8ba3f44360154a681 /dhcpv4/dhcpv4_test.go
parente252950ab9616e463bdb9e9ea84ff279cad761c8 (diff)
dhcpv4: change `NewRenewFromOffer` to `NewRenewFromAck`
Signed-off-by: Dennis Marttinen <twelho@welho.tech>
Diffstat (limited to 'dhcpv4/dhcpv4_test.go')
-rw-r--r--dhcpv4/dhcpv4_test.go27
1 files changed, 13 insertions, 14 deletions
diff --git a/dhcpv4/dhcpv4_test.go b/dhcpv4/dhcpv4_test.go
index d2d6edd..a961f78 100644
--- a/dhcpv4/dhcpv4_test.go
+++ b/dhcpv4/dhcpv4_test.go
@@ -266,23 +266,22 @@ func TestDHCPv4NewRequestFromOfferWithModifier(t *testing.T) {
require.Equal(t, MessageTypeRequest, req.MessageType())
}
-func TestDHCPv4NewRenewFromOffer(t *testing.T) {
- offer, err := New()
+func TestDHCPv4NewRenewFromAck(t *testing.T) {
+ ack, err := New()
require.NoError(t, err)
- offer.SetBroadcast()
- offer.UpdateOption(OptMessageType(MessageTypeOffer))
- offer.UpdateOption(OptServerIdentifier(net.IPv4(192, 168, 0, 1)))
- offer.UpdateOption(OptRequestedIPAddress(net.IPv4(192, 168, 0, 1)))
- offer.YourIPAddr = net.IPv4(192, 168, 0, 1)
+ ack.SetBroadcast()
+ ack.UpdateOption(OptMessageType(MessageTypeAck))
+ ack.UpdateOption(OptServerIdentifier(net.IPv4(192, 168, 0, 1)))
+ ack.YourIPAddr = net.IPv4(192, 168, 0, 1)
- // RFC 2131: RENEW-style requests will be unicast
var req *DHCPv4
- req, err = NewRenewFromOffer(offer)
+ req, err = NewRenewFromAck(ack)
require.NoError(t, err)
require.Equal(t, MessageTypeRequest, req.MessageType())
require.Nil(t, req.GetOneOption(OptionServerIdentifier))
require.Nil(t, req.GetOneOption(OptionRequestedIPAddress))
- require.Equal(t, offer.YourIPAddr, req.ClientIPAddr)
+ require.Equal(t, ack.YourIPAddr, req.ClientIPAddr)
+ // RFC 2131: RENEW-style requests will be unicast
require.True(t, req.IsUnicast())
require.False(t, req.IsBroadcast())
// Renewals should behave identically to initial requests regarding requested options
@@ -292,12 +291,12 @@ func TestDHCPv4NewRenewFromOffer(t *testing.T) {
require.True(t, req.IsOptionRequested(OptionDomainNameServer))
}
-func TestDHCPv4NewRenewFromOfferWithModifier(t *testing.T) {
- offer, err := New()
+func TestDHCPv4NewRenewFromAckWithModifier(t *testing.T) {
+ ack, err := New()
require.NoError(t, err)
- offer.UpdateOption(OptMessageType(MessageTypeOffer))
+ ack.UpdateOption(OptMessageType(MessageTypeAck))
userClass := WithUserClass("linuxboot", false)
- req, err := NewRenewFromOffer(offer, userClass)
+ req, err := NewRenewFromAck(ack, userClass)
require.NoError(t, err)
require.Equal(t, MessageTypeRequest, req.MessageType())
require.Contains(t, req.UserClass(), "linuxboot")