]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3773] Added unit tests for confirm and rebind
authorFrancis Dupont <fdupont@isc.org>
Fri, 4 Sep 2015 21:56:20 +0000 (23:56 +0200)
committerFrancis Dupont <fdupont@isc.org>
Fri, 4 Sep 2015 21:56:20 +0000 (23:56 +0200)
src/bin/dhcp6/tests/confirm_unittest.cc
src/bin/dhcp6/tests/dhcp6_test_utils.h
src/bin/dhcp6/tests/rebind_unittest.cc

index d4765d42e5f01493dff5d9d811e7655e2e6761ed..76e3048a9f6c75035a08ec590888cab3c2d55aec 100644 (file)
@@ -18,6 +18,7 @@
 #include <dhcp/tests/iface_mgr_test_config.h>
 #include <dhcp6/json_config_parser.h>
 #include <dhcp6/tests/dhcp6_message_test.h>
+#include <dhcpsrv/utils.h>
 
 using namespace isc;
 using namespace isc::asiolink;
@@ -98,6 +99,24 @@ public:
 };
 
 
+// Test that clientID is mandatory and serverID forbidden for Confirm messages
+TEST_F(ConfirmTest, sanityCheck) {
+    NakedDhcpv6Srv srv(0);
+
+    // No clientID should fail
+    Pkt6Ptr confirm = Pkt6Ptr(new Pkt6(DHCPV6_CONFIRM, 1234));
+    EXPECT_THROW(srv.processConfirm(confirm), RFCViolation);
+
+    // A clientID should succeed
+    OptionPtr clientid = generateClientId();
+    confirm->addOption(clientid);
+    EXPECT_NO_THROW(srv.processConfirm(confirm));
+
+    // A serverID should fail
+    confirm->addOption(srv.getServerID());
+    EXPECT_THROW(srv.processConfirm(confirm), RFCViolation);
+}
+
 // Test that directly connected client's Confirm message is processed and Reply
 // message is sent back. In this test case, the client sends Confirm for two
 // addresses that belong to the same IAID and are sent within the same IA_NA
index 6bc1334fcfe836261bef9b58ef14dde7bf9f1629..c6fcfad75d0e8f6da4cd5da0ea7e2ba9722daf75 100644 (file)
@@ -98,7 +98,11 @@ public:
     using Dhcpv6Srv::processSolicit;
     using Dhcpv6Srv::processRequest;
     using Dhcpv6Srv::processRenew;
+    using Dhcpv6Srv::processRebind;
+    using Dhcpv6Srv::processConfirm;
     using Dhcpv6Srv::processRelease;
+    using Dhcpv6Srv::processDecline;
+    using Dhcpv6Srv::processInfRequest;
     using Dhcpv6Srv::processClientFqdn;
     using Dhcpv6Srv::createNameChangeRequests;
     using Dhcpv6Srv::createRemovalNameChangeRequest;
index 2176a8b7d51b709a334348e12bc4f6cf5bd701f1..cfb96fc403ad27aa5dde7b4c52dbfbfc3bb44302 100644 (file)
@@ -18,6 +18,7 @@
 #include <dhcp/tests/iface_mgr_test_config.h>
 #include <dhcp6/json_config_parser.h>
 #include <dhcp6/tests/dhcp6_message_test.h>
+#include <dhcpsrv/utils.h>
 
 using namespace isc;
 using namespace isc::asiolink;
@@ -244,6 +245,24 @@ public:
     }
 };
 
+// Test that clientID is mandatory and serverID forbidden for Rebind messages
+TEST_F(RebindTest, sanityCheck) {
+    NakedDhcpv6Srv srv(0);
+
+    // No clientID should fail
+    Pkt6Ptr rebind = Pkt6Ptr(new Pkt6(DHCPV6_REBIND, 1234));
+    EXPECT_THROW(srv.processRebind(rebind), RFCViolation);
+
+    // A clientID should succeed
+    OptionPtr clientid = generateClientId();
+    rebind->addOption(clientid);
+    EXPECT_NO_THROW(srv.processRebind(rebind));
+
+    // A serverID should fail
+    rebind->addOption(srv.getServerID());
+    EXPECT_THROW(srv.processRebind(rebind), RFCViolation);
+}
+
 // Test that directly connected client's Rebind message is processed and Reply
 // message is sent back.
 TEST_F(RebindTest, directClient) {