"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/bin/dhcp4/tests/vendor_opts_unittest.cc" between
kea-1.6.1.tar.gz and kea-1.6.2.tar.gz

About: Kea is a modern DHCPv4 & DHCPv6 Server (potential successor of ISC DHCP).

vendor_opts_unittest.cc  (kea-1.6.1):vendor_opts_unittest.cc  (kea-1.6.2)
// Copyright (C) 2019 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2019-2020 Internet Systems Consortium, Inc. ("ISC")
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
// This file is dedicated to testing vendor options. There are several // This file is dedicated to testing vendor options. There are several
// vendor options in DHCPv4: // vendor options in DHCPv4:
// //
// vivso (125) - vendor independent vendor specific option. This is by far the // vivso (125) - vendor independent vendor specific option. This is by far the
// most popular // most popular
skipping to change at line 687 skipping to change at line 687
// Checks effect of raw not compatible option 43 (failure) // Checks effect of raw not compatible option 43 (failure)
TEST_F(VendorOptsTest, option43FailRaw) { TEST_F(VendorOptsTest, option43FailRaw) {
IfaceMgrTestConfig test_config(true); IfaceMgrTestConfig test_config(true);
IfaceMgr::instance().openSockets4(); IfaceMgr::instance().openSockets4();
NakedDhcpv4Srv srv(0); NakedDhcpv4Srv srv(0);
// The vendor-encapsulated-options has an incompatible data // The vendor-encapsulated-options has an incompatible data
// so won't have the expected content. Here the processing // so won't have the expected content. Here the processing
// of suboptions tries to unpack the uitn32 foo suboption and // of suboptions tries to unpack the uitn32 foo suboption and
// raises an exception. // raises an exception which is caught so the option stays unpacked.
string config = "{ \"interfaces-config\": {" string config = "{ \"interfaces-config\": {"
" \"interfaces\": [ \"*\" ] }, " " \"interfaces\": [ \"*\" ] }, "
"\"subnet4\": [ " "\"subnet4\": [ "
"{ \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ], " "{ \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ], "
" \"subnet\": \"192.0.2.0/24\" } ]," " \"subnet\": \"192.0.2.0/24\" } ],"
"\"option-def\": [ " "\"option-def\": [ "
"{ \"code\": 1, " "{ \"code\": 1, "
" \"name\": \"foo\", " " \"name\": \"foo\", "
" \"space\": \"vendor-encapsulated-options-space\", " " \"space\": \"vendor-encapsulated-options-space\", "
" \"type\": \"uint32\" } ]," " \"type\": \"uint32\" } ],"
skipping to change at line 745 skipping to change at line 745
// Create and add a PRL option to the query // Create and add a PRL option to the query
OptionUint8ArrayPtr prl(new OptionUint8Array(Option::V4, OptionUint8ArrayPtr prl(new OptionUint8Array(Option::V4,
DHO_DHCP_PARAMETER_REQUEST_LIST )); DHO_DHCP_PARAMETER_REQUEST_LIST ));
ASSERT_TRUE(prl); ASSERT_TRUE(prl);
prl->addValue(DHO_VENDOR_ENCAPSULATED_OPTIONS); prl->addValue(DHO_VENDOR_ENCAPSULATED_OPTIONS);
prl->addValue(DHO_VENDOR_CLASS_IDENTIFIER); prl->addValue(DHO_VENDOR_CLASS_IDENTIFIER);
query->addOption(prl); query->addOption(prl);
srv.classifyPacket(query); srv.classifyPacket(query);
EXPECT_THROW(srv.deferredUnpack(query), InvalidOptionValue); EXPECT_NO_THROW(srv.deferredUnpack(query));
ASSERT_TRUE(query->getOption(vopt->getType()));
EXPECT_EQ(vopt, query->getOption(vopt->getType()));
} }
// Verifies raw option 43 can be handled (global) // Verifies raw option 43 can be handled (global)
TEST_F(VendorOptsTest, option43RawGlobal) { TEST_F(VendorOptsTest, option43RawGlobal) {
IfaceMgrTestConfig test_config(true); IfaceMgrTestConfig test_config(true);
IfaceMgr::instance().openSockets4(); IfaceMgr::instance().openSockets4();
NakedDhcpv4Srv srv(0); NakedDhcpv4Srv srv(0);
// The vendor-encapsulated-options is redefined as raw binary // The vendor-encapsulated-options is redefined as raw binary
skipping to change at line 1324 skipping to change at line 1326
// Checks effect of raw not compatible option 43 sent by a client (failure) // Checks effect of raw not compatible option 43 sent by a client (failure)
TEST_F(VendorOptsTest, clientOption43FailRaw) { TEST_F(VendorOptsTest, clientOption43FailRaw) {
IfaceMgrTestConfig test_config(true); IfaceMgrTestConfig test_config(true);
IfaceMgr::instance().openSockets4(); IfaceMgr::instance().openSockets4();
Dhcp4Client client; Dhcp4Client client;
// The vendor-encapsulated-options has an incompatible data // The vendor-encapsulated-options has an incompatible data
// so won't have the expected content. Here the processing // so won't have the expected content. Here the processing
// of suboptions tries to unpack the uint32 foo suboption and // of suboptions tries to unpack the uint32 foo suboption and
// raises an exception. // raises an exception which is caught.
string config = "{ \"interfaces-config\": {" string config = "{ \"interfaces-config\": {"
" \"interfaces\": [ \"*\" ] }, " " \"interfaces\": [ \"*\" ] }, "
"\"subnet4\": [ " "\"subnet4\": [ "
"{ \"pools\": [ { \"pool\": \"10.0.0.10 - 10.0.0.100\" } ], " "{ \"pools\": [ { \"pool\": \"10.0.0.10 - 10.0.0.100\" } ], "
" \"subnet\": \"10.0.0.0/24\" } ]," " \"subnet\": \"10.0.0.0/24\" } ],"
"\"option-def\": [ " "\"option-def\": [ "
"{ \"code\": 1, " "{ \"code\": 1, "
" \"name\": \"foo\", " " \"name\": \"foo\", "
" \"space\": \"vendor-encapsulated-options-space\", " " \"space\": \"vendor-encapsulated-options-space\", "
" \"type\": \"uint32\" } ] }"; " \"type\": \"uint32\" } ] }";
skipping to change at line 1349 skipping to change at line 1351
// with not compatible (not parsable as suboptions) content // with not compatible (not parsable as suboptions) content
// which will raise an exception // which will raise an exception
OptionBuffer buf; OptionBuffer buf;
buf.push_back(0x01); buf.push_back(0x01);
buf.push_back(0x01); buf.push_back(0x01);
buf.push_back(0x01); buf.push_back(0x01);
OptionPtr vopt(new Option(Option::V4, DHO_VENDOR_ENCAPSULATED_OPTIONS, buf)) ; OptionPtr vopt(new Option(Option::V4, DHO_VENDOR_ENCAPSULATED_OPTIONS, buf)) ;
client.addExtraOption(vopt); client.addExtraOption(vopt);
// Let's check whether the server is not able to process this packet // Let's check whether the server is not able to process this packet
// and raises an exception so the response is empty. // and raises an exception which is caught so the response is not empty.
EXPECT_NO_THROW(client.doDiscover()); EXPECT_NO_THROW(client.doDiscover());
EXPECT_FALSE(client.getContext().response_); EXPECT_TRUE(client.getContext().response_);
} }
// Verifies raw option 43 sent by a client can be handled (global) // Verifies raw option 43 sent by a client can be handled (global)
TEST_F(VendorOptsTest, clientOption43RawGlobal) { TEST_F(VendorOptsTest, clientOption43RawGlobal) {
IfaceMgrTestConfig test_config(true); IfaceMgrTestConfig test_config(true);
IfaceMgr::instance().openSockets4(); IfaceMgr::instance().openSockets4();
Dhcp4Client client; Dhcp4Client client;
// The vendor-encapsulated-options is redefined as raw binary // The vendor-encapsulated-options is redefined as raw binary
// in a global definition. // in a global definition.
 End of changes. 6 change blocks. 
6 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)