]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#464,!238] Truncated vivso option moved to vendor_opts_unittest.cc
authorTomek Mrugalski <tomasz@isc.org>
Fri, 15 Feb 2019 12:44:42 +0000 (13:44 +0100)
committerTomek Mrugalski <tomasz@isc.org>
Tue, 19 Feb 2019 11:15:37 +0000 (12:15 +0100)
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/vendor_opts_unittest.cc

index f5dd3afd874d76dc2c25c1dde2744009d0be04bc..201fe3df37b82cdb54af38596b0f3d3f6ae78a16 100644 (file)
@@ -21,7 +21,6 @@
 #include <dhcp/option4_addrlst.h>
 #include <dhcp/option_custom.h>
 #include <dhcp/option_int_array.h>
-#include <dhcp/option_vendor.h>
 #include <dhcp/pkt_filter.h>
 #include <dhcp/pkt_filter_inet.h>
 #include <dhcp/tests/iface_mgr_test_config.h>
@@ -3282,63 +3281,6 @@ TEST_F(Dhcpv4SrvTest, userContext) {
     EXPECT_EQ("{ \"value\": 42 }", pools[0]->getContext()->str());
 }
 
-// Verifies that an a client query with a truncated length in
-// vendor option (125) will still be processed by the server.
-TEST_F(Dhcpv4SrvTest, truncatedVIVSOOption) {
-    IfaceMgrTestConfig test_config(true);
-    IfaceMgr::instance().openSockets4();
-
-    NakedDhcpv4Srv srv(0);
-
-    string config = "{ \"interfaces-config\": {"
-        "    \"interfaces\": [ \"*\" ]"
-        "},"
-        "\"rebind-timer\": 2000, "
-        "\"renew-timer\": 1000, "
-        "\"subnet4\": [ { "
-        "    \"pools\": [ { \"pool\": \"10.206.80.0/25\" } ],"
-        "    \"subnet\": \"10.206.80.0/24\", "
-        "    \"rebind-timer\": 2000, "
-        "    \"renew-timer\": 1000, "
-        "    \"valid-lifetime\": 4000,"
-        "    \"interface\": \"eth0\" "
-        " } ],"
-        "\"valid-lifetime\": 4000 }";
-
-    ConstElementPtr json;
-    ASSERT_NO_THROW(json = parseDHCP4(config));
-    ConstElementPtr status;
-
-    // Configure the server and make sure the config is accepted
-    EXPECT_NO_THROW(status = configureDhcp4Server(srv, json));
-    ASSERT_TRUE(status);
-    comment_ = config::parseAnswer(rcode_, status);
-    ASSERT_EQ(0, rcode_);
-
-    CfgMgr::instance().commit();
-
-    // Create a DISCOVER with a VIVSO option whose length is
-    // too short.
-    Pkt4Ptr dis;
-    ASSERT_NO_THROW(dis = PktCaptures::discoverWithTruncatedVIVSO());
-
-    // Simulate that we have received that traffic
-    srv.fakeReceive(dis);
-
-    // Server will now process to run its normal loop, but instead of calling
-    // IfaceMgr::receive4(), it will read all packets from the list set by
-    // fakeReceive()
-    // In particular, it should call registered buffer4_receive callback.
-    srv.run();
-
-    // Check that the server did send a response
-    ASSERT_EQ(1, srv.fake_sent_.size());
-
-    // Make sure that we received an response and it was an offer
-    Pkt4Ptr offer = srv.fake_sent_.front();
-    ASSERT_TRUE(offer);
-}
-
 /// @todo: Implement proper tests for MySQL lease/host database,
 ///        see ticket #4214.
 
index d76e0564a8486948fc864f23b5f8d77157205eac..cb702fbddc8bb3bae54bb33425b1d7c7759b3e59 100644 (file)
@@ -1419,3 +1419,59 @@ TEST_F(VendorOptsTest, clientOption43RawClass) {
     EXPECT_TRUE(client.getContext().response_);
 }
 
+// Verifies that an a client query with a truncated length in
+// vendor option (125) will still be processed by the server.
+TEST_F(Dhcpv4SrvTest, truncatedVIVSOOption) {
+    IfaceMgrTestConfig test_config(true);
+    IfaceMgr::instance().openSockets4();
+
+    NakedDhcpv4Srv srv(0);
+
+    string config = "{ \"interfaces-config\": {"
+        "    \"interfaces\": [ \"*\" ]"
+        "},"
+        "\"rebind-timer\": 2000, "
+        "\"renew-timer\": 1000, "
+        "\"subnet4\": [ { "
+        "    \"pools\": [ { \"pool\": \"10.206.80.0/25\" } ],"
+        "    \"subnet\": \"10.206.80.0/24\", "
+        "    \"rebind-timer\": 2000, "
+        "    \"renew-timer\": 1000, "
+        "    \"valid-lifetime\": 4000,"
+        "    \"interface\": \"eth0\" "
+        " } ],"
+        "\"valid-lifetime\": 4000 }";
+
+    ConstElementPtr json;
+    ASSERT_NO_THROW(json = parseDHCP4(config));
+    ConstElementPtr status;
+
+    // Configure the server and make sure the config is accepted
+    EXPECT_NO_THROW(status = configureDhcp4Server(srv, json));
+    ASSERT_TRUE(status);
+    comment_ = parseAnswer(rcode_, status);
+    ASSERT_EQ(0, rcode_);
+
+    CfgMgr::instance().commit();
+
+    // Create a DISCOVER with a VIVSO option whose length is
+    // too short.
+    Pkt4Ptr dis;
+    ASSERT_NO_THROW(dis = PktCaptures::discoverWithTruncatedVIVSO());
+
+    // Simulate that we have received that traffic
+    srv.fakeReceive(dis);
+
+    // Server will now process to run its normal loop, but instead of calling
+    // IfaceMgr::receive4(), it will read all packets from the list set by
+    // fakeReceive()
+    // In particular, it should call registered buffer4_receive callback.
+    srv.run();
+
+    // Check that the server did send a response
+    ASSERT_EQ(1, srv.fake_sent_.size());
+
+    // Make sure that we received an response and it was an offer
+    Pkt4Ptr offer = srv.fake_sent_.front();
+    ASSERT_TRUE(offer);
+}