-# Copyright (C) 2016-2019 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2016-2020 Internet Systems Consortium, Inc. ("ISC")
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
CONFIG="{
\"Control-agent\":
{
- \"http-host\": \"127.0.0.1\"
- },
- \"Logging\":
- {
+ \"http-host\": \"127.0.0.1\",
\"loggers\": [
{
\"name\": \"kea-ctrl-agent\",
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) {
"expecting }");
testError("{ 123 }\n",
ParserContext::PARSER_AGENT,
- "<string>:1.3-5: syntax error, unexpected integer");
+ "<string>:1.3-5: syntax error, unexpected integer, "
+ "expecting Control-agent");
testError("{ \"foo\" }\n",
ParserContext::PARSER_JSON,
"<string>:1.9: syntax error, unexpected }, "
"expecting :");
testError("{ \"foo\" }\n",
ParserContext::PARSER_AGENT,
- "<string>:1.9: syntax error, unexpected }, expecting :");
+ "<string>:1.3-7: syntax error, unexpected constant string, "
+ "expecting Control-agent");
testError("{ \"foo\":null }\n",
ParserContext::PARSER_AGENT,
- "<string>:1.3-7: got unexpected keyword "
- "\"foo\" in toplevel map.");
+ "<string>:1.3-7: syntax error, unexpected constant string, "
+ "expecting Control-agent");
+ testError("{ \"Logging\":null }\n",
+ ParserContext::PARSER_AGENT,
+ "<string>:1.3-11: syntax error, unexpected constant string, "
+ "expecting Control-agent");
testError("{ \"Control-agent\" }\n",
ParserContext::PARSER_AGENT,
"<string>:1.19: syntax error, unexpected }, "
EXPECT_EQ("////", result->stringValue());
}
-};
-};
-};
+}
+}
+}
-# Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2014-2020 Internet Systems Consortium, Inc. ("ISC")
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
\"port\": 53001,
\"tsig-keys\": [],
\"forward-ddns\" : {},
- \"reverse-ddns\" : {}
- },
- \"Logging\":
- {
+ \"reverse-ddns\" : {},
\"loggers\": [
{
\"name\": \"kea-dhcp-ddns\",
\"port\": BOGUS,
\"tsig-keys\": [],
\"forward-ddns\" : {},
- \"reverse-ddns\" : {}
- },
- \"Logging\":
- {
+ \"reverse-ddns\" : {},
\"loggers\": [
{
\"name\": \"kea-dhcp-ddns\",
\"port\": 80000,
\"tsig-keys\": [],
\"forward-ddns\" : {},
- \"reverse-ddns\" : {}
- },
- \"Logging\":
- {
+ \"reverse-ddns\" : {},
\"loggers\": [
{
\"name\": \"kea-dhcp-ddns\",
\"port\": BOGUS,
\"tsig-keys\": [],
\"forward-ddns\" : {},
- \"reverse-ddns\" : {}
- },
- \"Logging\":
- {
+ \"reverse-ddns\" : {},
\"loggers\": [
{
\"name\": \"kea-dhcp-ddns\",
-// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
testParser(txt, D2ParserContext::PARSER_DHCPDDNS);
}
-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, D2ParserContext::PARSER_DHCPDDNS);
-}
-
-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, D2ParserContext::PARSER_DHCPDDNS);
-}
-
-TEST(ParserTest, keywordControlAgent) {
- string txt = "{ \"Control-agent\": { } }";
- testParser(txt, D2ParserContext::PARSER_DHCPDDNS);
-}
-
-TEST(ParserTest, Logging) {
- string txt = "{ \"Logging\": { \n"
- " \"loggers\": [ \n"
- " { \n"
- " \"name\": \"kea-dhcp6\", \n"
- " \"output_options\": [ \n"
- " { \n"
- " \"output\": \"stdout\" \n"
- " } \n"
- " ], \n"
- " \"debuglevel\": 0, \n"
- " \"severity\": \"INFO\" \n"
- " } \n"
- " ] }\n"
- "} \n";
- testParser(txt, D2ParserContext::PARSER_DHCPDDNS);
-}
-
-
// Tests if bash (#) comments are supported. That's the only comment type that
// was supported by the old parser.
TEST(ParserTest, bashComments) {
"expecting }");
testError("{ 123 }\n",
D2ParserContext::PARSER_DHCPDDNS,
- "<string>:1.3-5: syntax error, unexpected integer");
+ "<string>:1.3-5: syntax error, unexpected integer, "
+ "expecting DhcpDdns");
testError("{ \"foo\" }\n",
D2ParserContext::PARSER_JSON,
"<string>:1.9: syntax error, unexpected }, "
"expecting :");
testError("{ \"foo\" }\n",
D2ParserContext::PARSER_DHCPDDNS,
- "<string>:1.9: syntax error, unexpected }, expecting :");
+ "<string>:1.3-7: syntax error, unexpected constant string, "
+ "expecting DhcpDdns");
testError("{ \"foo\":null }\n",
D2ParserContext::PARSER_DHCPDDNS,
- "<string>:1.3-7: got unexpected keyword "
- "\"foo\" in toplevel map.");
- testError("{ \"Dhcp6\" }\n",
- D2ParserContext::PARSER_DHCPDDNS,
- "<string>:1.11: syntax error, unexpected }, "
- "expecting :");
- testError("{ \"Dhcp4\":[]\n",
+ "<string>:1.3-7: syntax error, unexpected constant string, "
+ "expecting DhcpDdns");
+ testError("{ \"Logging\":null }\n",
D2ParserContext::PARSER_DHCPDDNS,
- "<string>:2.1: syntax error, unexpected end of file, "
- "expecting \",\" or }");
+ "<string>:1.3-11: syntax error, unexpected constant string, "
+ "expecting DhcpDdns");
testError("{}{}\n",
D2ParserContext::PARSER_JSON,
"<string>:1.3: syntax error, unexpected {, "
EXPECT_EQ("////", result->stringValue());
}
-};
-};
-};
+}
+}
+}
-// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
testError("{ 123 }\n",
ParserContext::PARSER_NETCONF,
"<string>:1.3-5: syntax error, unexpected integer, "
- "expecting Netconf or Logging");
+ "expecting Netconf");
testError("{ \"foo\" }\n",
ParserContext::PARSER_JSON,
"<string>:1.9: syntax error, unexpected }, "
testError("{ \"foo\" }\n",
ParserContext::PARSER_NETCONF,
"<string>:1.3-7: syntax error, unexpected constant string, "
- "expecting Netconf or Logging");
+ "expecting Netconf");
testError("{ \"foo\":null }\n",
ParserContext::PARSER_NETCONF,
"<string>:1.3-7: syntax error, unexpected constant string, "
- "expecting Netconf or Logging");
+ "expecting Netconf");
+ testError("{ \"Logging\":null }\n",
+ ParserContext::PARSER_NETCONF,
+ "<string>:1.3-11: syntax error, unexpected constant string, "
+ "expecting Netconf");
testError("{ \"Netconf\" }\n",
ParserContext::PARSER_NETCONF,
"<string>:1.13: syntax error, unexpected }, "
ParserContext::PARSER_NETCONF,
"<string>:3.3-11: duplicate user-context/comment entries "
"(previous at <string>:2:19)");
+
+ // duplicate Netconf entries
+ testError("{ \"Netconf\":{\n"
+ " \"comment\": \"first\" },\n"
+ " \"Netconf\":{\n"
+ " \"comment\": \"second\" }}\n",
+ ParserContext::PARSER_NETCONF,
+ "<string>:3:3: duplicate Netconf entries in toplevel map "
+ "(previous at <string>:1:3)");
}
// Check unicode escapes
EXPECT_EQ("////", result->stringValue());
}
-};
-};
-};
+}
+}
+}
-# Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
{
\"comment\": \"simply use defaults...\"
}
- }
- },
-
- \"Logging\":
- {
+ },
\"loggers\": [
{
\"name\": \"kea-netconf\",