summaryrefslogtreecommitdiffstats
path: root/src/bin/dhcp6/tests
diff options
context:
space:
mode:
authorMarcin Siodelski <marcin@isc.org>2015-11-24 20:26:08 +0100
committerMarcin Siodelski <marcin@isc.org>2015-11-24 20:26:08 +0100
commit97003370e91209cec068015369fe16b5a9146ef4 (patch)
tree6710b741aebd86578c153f76976ddedf050cb8ed /src/bin/dhcp6/tests
parent[4204] Specification of option name doesn't require quotes. (diff)
downloadkea-97003370e91209cec068015369fe16b5a9146ef4.tar.xz
kea-97003370e91209cec068015369fe16b5a9146ef4.zip
[4204] Runtime option definitions created using set/commit process.
Diffstat (limited to 'src/bin/dhcp6/tests')
-rw-r--r--src/bin/dhcp6/tests/config_parser_unittest.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc
index d08ee4a0c0..4ab9e9a4f1 100644
--- a/src/bin/dhcp6/tests/config_parser_unittest.cc
+++ b/src/bin/dhcp6/tests/config_parser_unittest.cc
@@ -1593,6 +1593,15 @@ TEST_F(Dhcp6ParserTest, optionDefIpv6Address) {
EXPECT_EQ(100, def->getCode());
EXPECT_FALSE(def->getArrayType());
EXPECT_EQ(OPT_IPV6_ADDRESS_TYPE, def->getType());
+
+ // The copy of the option definition should be available in the libdhcp++.
+ OptionDefinitionPtr def_libdhcp = LibDHCP::getRuntimeOptionDef("isc", 100);
+ ASSERT_TRUE(def_libdhcp);
+
+ // Both definitions should be held in distinct pointers but they should
+ // be equal.
+ EXPECT_TRUE(def_libdhcp != def);
+ EXPECT_TRUE(*def_libdhcp == *def);
}
// The goal of this test is to check whether an option definition
@@ -1702,6 +1711,14 @@ TEST_F(Dhcp6ParserTest, optionDefMultiple) {
// The goal of this test is to verify that the duplicated option
// definition is not accepted.
TEST_F(Dhcp6ParserTest, optionDefDuplicate) {
+ // Preconfigure libdhcp++ with option definitions. The new configuration
+ // should override it, but when the new configuration fails, it should
+ // revert to this original configuration.
+ OptionDefSpaceContainer defs;
+ OptionDefinitionPtr def(new OptionDefinition("bar", 233, "string"));
+ defs.addItem(def, "isc");
+ LibDHCP::setRuntimeOptionDefs(defs);
+ LibDHCP::commitRuntimeOptionDefs();
// Configuration string. Both option definitions have
// the same code and belong to the same option space.
@@ -1732,6 +1749,15 @@ TEST_F(Dhcp6ParserTest, optionDefDuplicate) {
ASSERT_TRUE(status);
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
+
+ // The new configuration should have inserted option 100, but
+ // once configuration failed (on the duplicate option definition)
+ // the original configuration in libdhcp++ should be reverted.
+ EXPECT_FALSE(LibDHCP::getRuntimeOptionDef("isc", 100));
+ def = LibDHCP::getRuntimeOptionDef("isc", 233);
+ ASSERT_TRUE(def);
+ EXPECT_EQ("bar", def->getName());
+ EXPECT_EQ(233, def->getCode());
}
// The goal of this test is to verify that the option definition