From: Francis Dupont Date: Sun, 1 Nov 2015 00:41:15 +0000 (+0100) Subject: [3927] Added a defaultSpaceOptionDefTest unit test X-Git-Tag: trac4115_base~5^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cedbc8083ee4be55671b5df6ccbc06834ae7baa9;p=thirdparty%2Fkea.git [3927] Added a defaultSpaceOptionDefTest unit test --- diff --git a/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc b/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc index 001a39303b..141e32c4f4 100644 --- a/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc +++ b/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc @@ -530,6 +530,39 @@ TEST_F(ParseConfigTest, minimalOptionDefTest) { EXPECT_TRUE(def->getEncapsulatedSpace().empty()); } +/// @brief Check parsing of option definitions using default dhcp6 space. +/// +/// Same than minimal but using the fact the default universe is V6 +/// so the default space is dhcp6 +TEST_F(ParseConfigTest, defaultSpaceOptionDefTest) { + + // Configuration string. + std::string config = + "{ \"option-def\": [ {" + " \"name\": \"foo\"," + " \"code\": 10000," + " \"type\": \"ipv6-address\"" + " } ]" + "}"; + + // Verify that the configuration string parses. + int rcode = parseConfiguration(config); + ASSERT_TRUE(rcode == 0); + + + // Verify that the option definition can be retrieved. + OptionDefinitionPtr def = + CfgMgr::instance().getStagingCfg()->getCfgOptionDef()->get("dhcp6", 10000); + ASSERT_TRUE(def); + + // Verify that the option definition is correct. + EXPECT_EQ("foo", def->getName()); + EXPECT_EQ(10000, def->getCode()); + EXPECT_FALSE(def->getArrayType()); + EXPECT_EQ(OPT_IPV6_ADDRESS_TYPE, def->getType()); + EXPECT_TRUE(def->getEncapsulatedSpace().empty()); +} + /// @brief Check basic parsing of options. /// /// Note that this tests basic operation of the OptionDataListParser and