BIND 10 dhcp-vendoropts, updated. 638c6a3abbc9e00f8609d7ea894219facc5dec71 [dhcp-vendoropts] Unit-tests written for csv-based vendor options
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat Oct 12 17:14:28 UTC 2013
The branch, dhcp-vendoropts has been updated
via 638c6a3abbc9e00f8609d7ea894219facc5dec71 (commit)
from 12035904417740858ad86de2cbaae044e02c590e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 638c6a3abbc9e00f8609d7ea894219facc5dec71
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Sat Oct 12 19:14:10 2013 +0200
[dhcp-vendoropts] Unit-tests written for csv-based vendor options
-----------------------------------------------------------------------
Summary of changes:
src/bin/dhcp6/tests/config_parser_unittest.cc | 28 +++++++--------
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc | 47 ++++++++++++++++---------
2 files changed, 43 insertions(+), 32 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc
index 9e0401e..1773c23 100644
--- a/src/bin/dhcp6/tests/config_parser_unittest.cc
+++ b/src/bin/dhcp6/tests/config_parser_unittest.cc
@@ -2108,7 +2108,7 @@ TEST_F(Dhcp6ParserTest, vendorOptionsHex) {
// This test checks if vendor options can be specified in the config file,
// (in csv format), and later retrieved from configured subnet
-TEST_F(Dhcp6ParserTest, DISABLED_vendorOptionsCsv) {
+TEST_F(Dhcp6ParserTest, vendorOptionsCsv) {
// This configuration string is to configure two options
// sharing the code 1 and belonging to the different vendor spaces.
@@ -2117,18 +2117,20 @@ TEST_F(Dhcp6ParserTest, DISABLED_vendorOptionsCsv) {
"\"rebind-timer\": 2000,"
"\"renew-timer\": 1000,"
"\"option-data\": [ {"
- " \"name\": \"option-one\","
+ " \"name\": \"foo\","
" \"space\": \"vendor-4491\","
" \"code\": 1,"
- " \"data\": \"AB CDEF0105\","
+ " \"data\": \"this is a string vendor-opt\","
" \"csv-format\": True"
- " },"
- " {"
- " \"name\": \"option-two\","
- " \"space\": \"vendor-1234\","
+ " } ],"
+ "\"option-def\": [ {"
+ " \"name\": \"foo\","
" \"code\": 1,"
- " \"data\": \"1234\","
- " \"csv-format\": True"
+ " \"type\": \"string\","
+ " \"array\": False,"
+ " \"record-types\": \"\","
+ " \"space\": \"vendor-4491\","
+ " \"encapsulate\": \"\""
" } ],"
"\"subnet6\": [ { "
" \"pool\": [ \"2001:db8:1::/80\" ],"
@@ -2152,15 +2154,11 @@ TEST_F(Dhcp6ParserTest, DISABLED_vendorOptionsCsv) {
Subnet::OptionDescriptor desc1 = subnet->getVendorOptionDescriptor(4491, 1);
ASSERT_TRUE(desc1.option);
EXPECT_EQ(1, desc1.option->getType());
- // Try to get the option from the vendor space 1234
- Subnet::OptionDescriptor desc2 = subnet->getVendorOptionDescriptor(1234, 1);
- ASSERT_TRUE(desc2.option);
- EXPECT_EQ(1, desc1.option->getType());
// Try to get the non-existing option from the non-existing
// option space and expect that option is not returned.
- Subnet::OptionDescriptor desc3 = subnet->getVendorOptionDescriptor(5678, 38);
- ASSERT_FALSE(desc3.option);
+ Subnet::OptionDescriptor desc2 = subnet->getVendorOptionDescriptor(5678, 38);
+ ASSERT_FALSE(desc2.option);
}
// The goal of this test is to verify that the standard option can
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index 61e7212..8da2df3 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -27,6 +27,7 @@
#include <dhcp/option_int.h>
#include <dhcp/option_vendor.h>
#include <dhcp/option_int_array.h>
+#include <dhcp/option_string.h>
#include <dhcp/iface_mgr.h>
#include <dhcp6/config_parser.h>
#include <dhcp/dhcp6.h>
@@ -2084,23 +2085,31 @@ TEST_F(Dhcpv6SrvTest, vendorOptionsORO) {
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
+ " \"option-def\": [ {"
+ " \"name\": \"config-file\","
+ " \"code\": 33,"
+ " \"type\": \"string\","
+ " \"array\": False,"
+ " \"record-types\": \"\","
+ " \"space\": \"vendor-4491\","
+ " \"encapsulate\": \"\""
+ " } ],"
+ " \"option-data\": [ {"
+ " \"name\": \"config-file\","
+ " \"space\": \"vendor-4491\","
+ " \"code\": 33,"
+ " \"data\": \"normal_erouter_v6.cm\","
+ " \"csv-format\": True"
+ " }],"
"\"subnet6\": [ { "
" \"pool\": [ \"2001:db8:1::/64\" ],"
" \"subnet\": \"2001:db8:1::/48\", "
- " \"option-data\": [ {"
- " \"name\": \"dns-servers\","
- " \"space\": \"vendor-4491\","
- " \"code\": 5,"
- " \"data\": \"1234567890\","
- " \"csv-format\": False"
- " },"
- " {"
- " \"name\": \"subscriber-id\","
- " \"space\": \"vendor-4491\","
- " \"code\": 6,"
- " \"data\": \"abcdef\","
- " \"csv-format\": False"
- " } ]"
+ " \"renew-timer\": 1000, "
+ " \"rebind-timer\": 1000, "
+ " \"preferred-lifetime\": 3000,"
+ " \"valid-lifetime\": 4000,"
+ " \"interface-id\": \"\","
+ " \"interface\": \"\""
" } ],"
"\"valid-lifetime\": 4000 }";
@@ -2134,7 +2143,7 @@ TEST_F(Dhcpv6SrvTest, vendorOptionsORO) {
// That suboption has code 1 and is a docsis ORO option.
boost::shared_ptr<OptionUint16Array> vendor_oro(new OptionUint16Array(Option::V6,
DOCSIS3_V6_ORO));
- vendor_oro->addValue(5); // Request option 5
+ vendor_oro->addValue(DOCSIS3_V6_CONFIG_FILE); // Request option 33
OptionPtr vendor(new OptionVendor(Option::V6, 4491));
vendor->addOption(vendor_oro);
sol->addOption(vendor);
@@ -2152,8 +2161,12 @@ TEST_F(Dhcpv6SrvTest, vendorOptionsORO) {
boost::dynamic_pointer_cast<OptionVendor>(tmp);
ASSERT_TRUE(vendor_resp);
- ASSERT_TRUE(vendor_resp->getOption(5)); // We requested it
- ASSERT_FALSE(vendor_resp->getOption(6)); // We did not request it
+ OptionPtr docsis33 = vendor_resp->getOption(33);
+ ASSERT_TRUE(docsis33);
+
+ OptionStringPtr config_file = boost::dynamic_pointer_cast<OptionString>(docsis33);
+ ASSERT_TRUE(config_file);
+ EXPECT_EQ("normal_erouter_v6.cm", config_file->getValue());
}
// This test verifies that the following option structure can be parsed:
More information about the bind10-changes
mailing list