]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#464,!238] vivsoInResponseOnly fixed.
authorTomek Mrugalski <tomasz@isc.org>
Fri, 15 Feb 2019 15:32:02 +0000 (16:32 +0100)
committerTomek Mrugalski <tomasz@isc.org>
Tue, 19 Feb 2019 11:15:37 +0000 (12:15 +0100)
src/bin/dhcp4/tests/vendor_opts_unittest.cc

index f05301170894f3328995e848b3206c4fed4cd3e7..f69dfc4f8868ff21cf34fd1a60be1f881ab4ed3a 100644 (file)
@@ -453,7 +453,7 @@ TEST_F(VendorOptsTest, docsisClientClassification) {
 // Checks that it's possible to have a vivso (125) option in the response
 // only. Once specific client (Genexis) sends only vendor-class info and
 // expects the server to include vivso in the response.
-TEST_F(VendorOptsTest, vendorInResponseOnly) {
+TEST_F(VendorOptsTest, vivsoInResponseOnly) {
     IfaceMgrTestConfig test_config(true);
     IfaceMgr::instance().openSockets4();
     Dhcp4Client client;
@@ -469,8 +469,6 @@ TEST_F(VendorOptsTest, vendorInResponseOnly) {
         "    \"interfaces-config\": {"
         "        \"interfaces\": [ \"*\" ]"
         "    },"
-        "    \"rebind-timer\": 2000, "
-        "    \"renew-timer\": 1000, "
         "    \"option-def\": ["
         "        {"
         "            \"name\": \"tftp\","
@@ -498,12 +496,9 @@ TEST_F(VendorOptsTest, vendorInResponseOnly) {
         "\"subnet4\": [ { "
         "    \"pools\": [ { \"pool\": \"192.0.2.0/25\" } ],"
         "    \"subnet\": \"192.0.2.0/24\", "
-        "    \"rebind-timer\": 2000, "
-        "    \"renew-timer\": 1000, "
-        "    \"valid-lifetime\": 4000,"
         "    \"interface\": \"eth0\" "
-        " } ],"
-        "\"valid-lifetime\": 4000 }";
+        " } ]"
+        "}";
 
     EXPECT_NO_THROW(configure(config, *client.getServer()));
 
@@ -511,18 +506,29 @@ TEST_F(VendorOptsTest, vendorInResponseOnly) {
     OptionPtr vopt(new OptionString(Option::V4, DHO_VENDOR_CLASS_IDENTIFIER,
                                     "HMC1000.v1.3.0-R,Element-P1090,genexis.eu"));
     client.addExtraOption(vopt);
+    client.requestOptions(DHO_VIVSO_SUBOPTIONS);
 
     // Let's check whether the server is not able to process this packet
-    // and raises an exception so the response is empty.
+    // and include vivso with appropriate sub-options
     EXPECT_NO_THROW(client.doDiscover());
     ASSERT_TRUE(client.getContext().response_);
 
-    OptionPtr rsp = client.getContext().response_->getOption(DHO_VENDOR_ENCAPSULATED_OPTIONS);
+    // Check there's a response.
+    OptionPtr rsp = client.getContext().response_->getOption(DHO_VIVSO_SUBOPTIONS);
     ASSERT_TRUE(rsp);
-    EXPECT_EQ("HMC1000.v1.3.0-R,Element-P1090,genexis.eu",
-              rsp->toText());
-}
 
+    // Check that it includes vivso with vendor-id = 25167
+    OptionVendorPtr rsp_vivso = boost::dynamic_pointer_cast<OptionVendor>(rsp);
+    ASSERT_TRUE(rsp_vivso);
+    EXPECT_EQ(25167, rsp_vivso->getVendorId());
+
+    // Now check that it contains suboption 2 with appropriate content.
+    OptionPtr subopt2 = rsp_vivso->getOption(2);
+    ASSERT_TRUE(subopt2);
+    vector<uint8_t> subopt2bin = subopt2->toBinary(false);
+    string txt(subopt2bin.begin(), subopt2bin.end());
+    EXPECT_EQ("tftp://192.0.2.1/genexis/HMC1000.v1.3.0-R.img", txt);
+}
 
 // Verifies last resort option 43 is backward compatible
 TEST_F(VendorOptsTest, option43LastResort) {