summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarcin Siodelski <marcin@isc.org>2017-07-13 15:48:39 +0200
committerMarcin Siodelski <marcin@isc.org>2017-07-13 15:48:39 +0200
commitdce538b3569283678ab504c05db19ca1c48cfb11 (patch)
treef31083e1015d8a18bd1f4450c3d3ebfb12416c8d /src
parent[5108] Updated keactrl section in User's Guide. (diff)
downloadkea-dce538b3569283678ab504c05db19ca1c48cfb11.tar.xz
kea-dce538b3569283678ab504c05db19ca1c48cfb11.zip
[5108] Addressed review comments.
Added unit tests that check that configuration of various servers can coexist.
Diffstat (limited to 'src')
-rw-r--r--src/bin/agent/tests/parser_unittests.cc48
-rw-r--r--src/bin/d2/tests/parser_unittest.cc5
-rw-r--r--src/bin/dhcp4/tests/kea_controller_unittest.cc25
-rw-r--r--src/bin/dhcp6/tests/kea_controller_unittest.cc26
4 files changed, 104 insertions, 0 deletions
diff --git a/src/bin/agent/tests/parser_unittests.cc b/src/bin/agent/tests/parser_unittests.cc
index 07d3a56330..c651eaab6e 100644
--- a/src/bin/agent/tests/parser_unittests.cc
+++ b/src/bin/agent/tests/parser_unittests.cc
@@ -117,6 +117,54 @@ TEST(ParserTest, keywordJSON) {
testParser(txt, ParserContext::PARSER_JSON);
}
+// This test checks that the DhcpDdns configuration is accepted
+// by the parser.
+TEST(ParserTest, keywordDhcpDdns) {
+ string txt =
+ "{ \"DhcpDdns\" : \n"
+ "{ \n"
+ " \"ip-address\": \"192.168.77.1\", \n"
+ " \"port\": 777 , \n "
+ " \"ncr-protocol\": \"UDP\", \n"
+ "\"tsig-keys\": [], \n"
+ "\"forward-ddns\" : {}, \n"
+ "\"reverse-ddns\" : {} \n"
+ "} \n"
+ "} \n";
+ testParser(txt, ParserContext::PARSER_AGENT);
+}
+
+// This test checks that the Dhcp6 configuration is accepted
+// by the parser.
+TEST(ParserTest, keywordDhcp6) {
+ string txt = "{ \"Dhcp6\": { \"interfaces-config\": {"
+ " \"interfaces\": [ \"type\", \"htype\" ] },\n"
+ "\"preferred-lifetime\": 3000,\n"
+ "\"rebind-timer\": 2000, \n"
+ "\"renew-timer\": 1000, \n"
+ "\"subnet6\": [ { "
+ " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
+ " \"subnet\": \"2001:db8:1::/48\", "
+ " \"interface\": \"test\" } ],\n"
+ "\"valid-lifetime\": 4000 } }";
+ testParser(txt, ParserContext::PARSER_AGENT);
+}
+
+// This test checks that the Dhcp4 configuration is accepted
+// by the parser.
+TEST(ParserTest, keywordDhcp4) {
+ string txt = "{ \"Dhcp4\": { \"interfaces-config\": {"
+ " \"interfaces\": [ \"type\", \"htype\" ] },\n"
+ "\"rebind-timer\": 2000, \n"
+ "\"renew-timer\": 1000, \n"
+ "\"subnet4\": [ { "
+ " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
+ " \"subnet\": \"192.0.2.0/24\", "
+ " \"interface\": \"test\" } ],\n"
+ "\"valid-lifetime\": 4000 } }";
+ testParser(txt, ParserContext::PARSER_AGENT);
+}
+
// This test checks if full config (with top level and Control-agent objects) can
// be parsed with syntactic checking (and as pure JSON).
TEST(ParserTest, keywordAgent) {
diff --git a/src/bin/d2/tests/parser_unittest.cc b/src/bin/d2/tests/parser_unittest.cc
index 285981d509..0a23f0db7b 100644
--- a/src/bin/d2/tests/parser_unittest.cc
+++ b/src/bin/d2/tests/parser_unittest.cc
@@ -159,6 +159,11 @@ TEST(ParserTest, keywordDhcp4) {
testParser(txt, D2ParserContext::PARSER_DHCPDDNS);
}
+TEST(ParserTest, keywordControlAgent) {
+ string txt = "{ \"Control-agent\": { } }";
+ testParser(txt, D2ParserContext::PARSER_DHCPDDNS);
+}
+
TEST(ParserTest, Logging) {
string txt = "{ \"Logging\": { \n"
" \"loggers\": [ \n"
diff --git a/src/bin/dhcp4/tests/kea_controller_unittest.cc b/src/bin/dhcp4/tests/kea_controller_unittest.cc
index ccd444a912..88a24f7a56 100644
--- a/src/bin/dhcp4/tests/kea_controller_unittest.cc
+++ b/src/bin/dhcp4/tests/kea_controller_unittest.cc
@@ -183,6 +183,31 @@ TEST_F(JSONFileBackendTest, jsonFile) {
EXPECT_EQ(Lease::TYPE_V4, pools3.at(0)->getType());
}
+// This test verifies that the configurations for various servers
+// can coexist and that the DHCPv4 configuration parsers will simply
+// ignore them.
+TEST_F(JSONFileBackendTest, serverConfigurationsCoexistence) {
+ std::string config = "{ \"Dhcp4\": {"
+ "\"rebind-timer\": 2000, "
+ "\"renew-timer\": 1000, \n"
+ "\"valid-lifetime\": 4000 }, "
+ "\"Dhcp6\": { },"
+ "\"DhcpDdns\": { },"
+ "\"Control-agent\": { }"
+ "}";
+
+ writeFile(TEST_FILE, config);
+
+ // Now initialize the server
+ boost::scoped_ptr<ControlledDhcpv4Srv> srv;
+ ASSERT_NO_THROW(
+ srv.reset(new ControlledDhcpv4Srv(0))
+ );
+
+ // And configure it using the config file.
+ EXPECT_NO_THROW(srv->init(TEST_FILE));
+}
+
// This test checks if configuration can be read from a JSON file
// using hash (#) line comments
TEST_F(JSONFileBackendTest, hashComments) {
diff --git a/src/bin/dhcp6/tests/kea_controller_unittest.cc b/src/bin/dhcp6/tests/kea_controller_unittest.cc
index 5ed89fbee1..9856f5da11 100644
--- a/src/bin/dhcp6/tests/kea_controller_unittest.cc
+++ b/src/bin/dhcp6/tests/kea_controller_unittest.cc
@@ -169,6 +169,32 @@ TEST_F(JSONFileBackendTest, jsonFile) {
EXPECT_EQ(Lease::TYPE_NA, pools3.at(0)->getType());
}
+// This test verifies that the configurations for various servers
+// can coexist and that the DHCPv6 configuration parsers will simply
+// ignore them.
+TEST_F(JSONFileBackendTest, serverConfigurationsCoexistence) {
+ std::string config = "{ \"Dhcp6\": {"
+ "\"rebind-timer\": 2000, "
+ "\"renew-timer\": 1000, \n"
+ "\"preferred-lifetime\": 1000, \n"
+ "\"valid-lifetime\": 4000 }, "
+ "\"Dhcp4\": { },"
+ "\"DhcpDdns\": { },"
+ "\"Control-agent\": { }"
+ "}";
+
+ writeFile(TEST_FILE, config);
+
+ // Now initialize the server
+ boost::scoped_ptr<ControlledDhcpv6Srv> srv;
+ ASSERT_NO_THROW(
+ srv.reset(new ControlledDhcpv6Srv(0))
+ );
+
+ // And configure it using the config file.
+ EXPECT_NO_THROW(srv->init(TEST_FILE));
+}
+
// This test checks if configuration can be read from a JSON file
// using hash (#) line comments
TEST_F(JSONFileBackendTest, hashComments) {