/// placed.
void sendHttpCommand(const string& command, string& response) {
response = "";
- IOServicePtr io_service = getIOService();
- ASSERT_TRUE(io_service);
+ IOServicePtr io_service = getIOService();
+ ASSERT_TRUE(io_service);
boost::scoped_ptr<TestHttpClient> client;
client.reset(new TestHttpClient(io_service, SERVER_ADDRESS,
SERVER_PORT));
testParser(txt, D2ParserContext::PARSER_DHCPDDNS, false);
}
+/// @brief Tests control socket config conflicts.
+TEST(ParserTest, duplicateControlSocket) {
+ // Valid configuration.
+ string txt(R"({
+ "DhcpDdns": {
+ "control-socket": {
+ "socket-type": "http",
+ "socket-address": "127.0.0.1"
+ }
+ }
+})");
+ testParser(txt, D2ParserContext::PARSER_DHCPDDNS, false);
+
+ // Invalid configuration: both map and list.
+ string bad1(R"({
+ "DhcpDdns": {
+ "control-socket": {
+ "socket-type": "http",
+ "socket-address": "127.0.0.1"
+ },
+ "control-sockets": [ ]
+ }
+})");
+
+ ASSERT_NO_THROW(Element::fromJSON(bad1, true));
+ D2ParserContext ctx1;
+ EXPECT_THROW(ctx1.parseString(bad1, D2ParserContext::PARSER_DHCPDDNS),
+ D2ParseError);
+
+ // Invalid configuration: both name and address.
+ string bad2(R"({
+ "DhcpDdns": {
+ "control-socket": {
+ "socket-type": "http",
+ "socket-address": "127.0.0.1",
+ "socket-name": "::1"
+ }
+ }
+})");
+
+ ASSERT_NO_THROW(Element::fromJSON(bad1, true));
+ D2ParserContext ctx2;
+ EXPECT_THROW(ctx2.parseString(bad2, D2ParserContext::PARSER_DHCPDDNS),
+ D2ParseError);
+}
+
} // namespace test
} // namespace d2
} // namespace isc
testParser(txt, Parser4Context::PARSER_DHCP4, false);
}
+/// @brief Tests control socket config conflicts.
+TEST(ParserTest, duplicateControlSocket) {
+ // Valid configuration.
+ string txt(R"({
+ "Dhcp4": {
+ "control-socket": {
+ "socket-type": "http",
+ "socket-address": "127.0.0.1"
+ }
+ }
+})");
+ testParser(txt, Parser4Context::PARSER_DHCP4, false);
+
+ // Invalid configuration: both map and list.
+ string bad1(R"({
+ "Dhcp4": {
+ "control-socket": {
+ "socket-type": "http",
+ "socket-address": "127.0.0.1"
+ },
+ "control-sockets": [ ]
+ }
+})");
+
+ ASSERT_NO_THROW(Element::fromJSON(bad1, true));
+ Parser4Context ctx1;
+ EXPECT_THROW(ctx1.parseString(bad1, Parser4Context::PARSER_DHCP4),
+ Dhcp4ParseError);
+
+ // Invalid configuration: both name and address.
+ string bad2(R"({
+ "Dhcp4": {
+ "control-socket": {
+ "socket-type": "http",
+ "socket-address": "127.0.0.1",
+ "socket-name": "::1"
+ }
+ }
+})");
+
+ ASSERT_NO_THROW(Element::fromJSON(bad1, true));
+ Parser4Context ctx2;
+ EXPECT_THROW(ctx2.parseString(bad2, Parser4Context::PARSER_DHCP4),
+ Dhcp4ParseError);
+}
+
} // namespace test
} // namespace dhcp
} // namespace isc
testParser(txt, Parser6Context::PARSER_DHCP6, false);
}
+/// @brief Tests control socket config conflicts.
+TEST(ParserTest, duplicateControlSocket) {
+ // Valid configuration.
+ string txt(R"({
+ "Dhcp6": {
+ "control-socket": {
+ "socket-type": "http",
+ "socket-address": "::1"
+ }
+ }
+})");
+ testParser(txt, Parser6Context::PARSER_DHCP6, false);
+
+ // Invalid configuration: both map and list.
+ string bad1(R"({
+ "Dhcp6": {
+ "control-socket": {
+ "socket-type": "http",
+ "socket-address": "::1"
+ },
+ "control-sockets": [ ]
+ }
+})");
+
+ ASSERT_NO_THROW(Element::fromJSON(bad1, true));
+ Parser6Context ctx1;
+ EXPECT_THROW(ctx1.parseString(bad1, Parser6Context::PARSER_DHCP6),
+ Dhcp6ParseError);
+
+ // Invalid configuration: both name and address.
+ string bad2(R"({
+ "Dhcp6": {
+ "control-socket": {
+ "socket-type": "http",
+ "socket-address": "::1",
+ "socket-name": "127.0.0.1"
+ }
+ }
+})");
+
+ ASSERT_NO_THROW(Element::fromJSON(bad1, true));
+ Parser6Context ctx2;
+ EXPECT_THROW(ctx2.parseString(bad2, Parser6Context::PARSER_DHCP6),
+ Dhcp6ParseError);
+}
+
} // namespace test
} // namespace dhcp
} // namespace isc