TEST(ParserTest, listInList) {
string txt = "[ [ \"Britain\", \"Wales\", \"Scotland\" ], "
- "[ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
+ " [ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
testParser(txt, ParserContext::PARSER_JSON);
}
TEST(ParserTest, listsInMaps) {
string txt = "{ \"constellations\": { \"orion\": [ \"rigel\", \"betelgeuse\" ], "
- "\"cygnus\": [ \"deneb\", \"albireo\"] } }";
+ "\"cygnus\": [ \"deneb\", \"albireo\"] } }";
testParser(txt, ParserContext::PARSER_JSON);
}
TEST(ParserTest, mapsInLists) {
string txt = "[ { \"body\": \"earth\", \"gravity\": 1.0 },"
- " { \"body\": \"mars\", \"gravity\": 0.376 } ]";
+ " { \"body\": \"mars\", \"gravity\": 0.376 } ]";
testParser(txt, ParserContext::PARSER_JSON);
}
" }"
" ]"
"}";
-
// This is only a subset of full config, so we'll parse with PARSER_SUB_AGENT.
testParser(txt, ParserContext::PARSER_SUB_AGENT);
testParser(txt, ParserContext::PARSER_JSON);
// Tests if bash (#) comments are supported. That's the only comment type that
// was supported by the old parser.
TEST(ParserTest, bashComments) {
- string txt= "{ \"Control-agent\": {"
- " \"http-host\": \"localhost\","
- " \"http-port\": 9000,\n"
- " \"control-sockets\": {\n"
- " \"d2\": {\n"
- "# this is a comment\n"
- "\"socket-type\": \"unix\", \n"
- "# This socket is mine. I can name it whatever\n"
- "# I like, ok?\n"
- "\"socket-name\": \"Hector\" \n"
- "} } } }";
+ string txt = "{ \"Control-agent\": {"
+ " \"http-host\": \"localhost\","
+ " \"http-port\": 9000,\n"
+ " \"control-sockets\": {\n"
+ " \"d2\": {\n"
+ "# this is a comment\n"
+ " \"socket-type\": \"unix\", \n"
+ "# This socket is mine. I can name it whatever\n"
+ "# I like, ok?\n"
+ " \"socket-name\": \"Hector\" \n"
+ "} } } }";
testParser(txt, ParserContext::PARSER_AGENT);
}
// Tests if C++ (//) comments can start anywhere, not just in the first line.
TEST(ParserTest, cppComments) {
- string txt= "{ \"Control-agent\": {"
- " \"http-host\": \"localhost\","
- " \"http-port\": 9001, // the level is over 9000!\n"
- " \"control-sockets\": {\n"
- " // Let's try talking to D2. Sadly, it never talks"
- " // to us back :( Maybe he doesn't like his name?\n"
- " \"d2\": {"
- "\"socket-type\": \"unix\", \n"
- "\"socket-name\": \"Hector\" \n"
- "} } } }";
-
+ string txt = "{ \"Control-agent\": {"
+ " \"http-host\": \"localhost\","
+ " \"http-port\": 9001, // the level is over 9000!\n"
+ " \"control-sockets\": {\n"
+ " // Let's try talking to D2. Sadly, it never talks"
+ " // to us back :( Maybe he doesn't like his name?\n"
+ " \"d2\": {"
+ " \"socket-type\": \"unix\", \n"
+ " \"socket-name\": \"Hector\" \n"
+ "} } } }";
testParser(txt, ParserContext::PARSER_AGENT, false);
}
" \"http-port\": 9000,\n"
" \"control-sockets\": {\n"
" \"d2\": {"
- "\"socket-type\": \"unix\", # Maybe Hector is not really a \n"
- "\"socket-name\": \"Hector\" # Unix process?\n"
+ " \"socket-type\": \"unix\", # Maybe Hector is not really a \n"
+ " \"socket-name\": \"Hector\" # Unix process?\n"
"# Oh no! He's a windows one and just pretending!\n"
"} } } }";
testParser(txt, ParserContext::PARSER_AGENT, false);
// Tests if multi-line C style comments are handled correctly.
TEST(ParserTest, multilineComments) {
- string txt= "{ \"Control-agent\": {"
- " \"http-host\": \"localhost\","
- " \"http-port\": 9000,\n"
- " \"control-sockets\": {\n"
- " \"dhcp4\": {\n"
- " \"socket-type\": \"unix\"\n"
- " }\n"
- " /* Ok, forget about it. If Hector doesn't want to talk,\n"
- " we won't talk to him either. We now have quiet days. */\n"
- " /* \"d2\": {"
- " \"socket-type\": \"unix\",\n"
- "\"socket-name\": \"Hector\"\n"
- "}*/ } } }";
+ string txt = "{ \"Control-agent\": {"
+ " \"http-host\": \"localhost\","
+ " \"http-port\": 9000,\n"
+ " \"control-sockets\": {\n"
+ " \"dhcp4\": {\n"
+ " \"socket-type\": \"unix\"\n"
+ " }\n"
+ " /* Ok, forget about it. If Hector doesn't want to talk,\n"
+ " we won't talk to him either. We now have quiet days. */\n"
+ " /* \"d2\": {"
+ " \"socket-type\": \"unix\",\n"
+ " \"socket-name\": \"Hector\"\n"
+ "}*/ } } }";
testParser(txt, ParserContext::PARSER_AGENT, false);
}
// Tests if embedded comments are handled correctly.
TEST(ParserTest, embbededComments) {
- string txt= "{ \"Control-agent\": {"
- " \"comment\": \"a comment\","
- " \"http-host\": \"localhost\","
- " \"http-port\": 9000,\n"
- " \"control-sockets\": {\n"
- " \"dhcp4\": {\n"
- " \"user-context\": { \"comment\": \"indirect\" },\n"
- " \"socket-type\": \"unix\"\n"
- " } },\n"
- " \"user-context\": { \"compatible\": true }\n"
- "} }";
+ string txt = "{ \"Control-agent\": {"
+ " \"comment\": \"a comment\","
+ " \"http-host\": \"localhost\","
+ " \"http-port\": 9000,\n"
+ " \"control-sockets\": {\n"
+ " \"dhcp4\": {\n"
+ " \"user-context\": { \"comment\": \"indirect\" },\n"
+ " \"socket-type\": \"unix\"\n"
+ " } },\n"
+ " \"user-context\": { \"compatible\": true }\n"
+ "} }";
testParser(txt, ParserContext::PARSER_AGENT, false);
}
// Test that output-options is an alias of output_options.
TEST(ParserTest, outputDashOptions) {
- string txt= "{ \"Control-agent\": {"
- " \"loggers\": [ { "
- " \"name\": \"kea-ctrl-agent\","
- " \"output-options\": [ { \"output\": \"stdout\" } ],"
- " \"severity\": \"INFO\" } ]"
- "} }";
+ string txt = "{ \"Control-agent\": {"
+ " \"loggers\": [ { "
+ " \"name\": \"kea-ctrl-agent\","
+ " \"output-options\": [ { \"output\": \"stdout\" } ],"
+ " \"severity\": \"INFO\" } ]"
+ "} }";
testParser(txt, ParserContext::PARSER_AGENT, false);
}
TEST(ParserTest, listInList) {
string txt = "[ [ \"Britain\", \"Wales\", \"Scotland\" ], "
- "[ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
+ " [ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
testParser(txt, D2ParserContext::PARSER_JSON);
}
TEST(ParserTest, listsInMaps) {
string txt = "{ \"constellations\": { \"orion\": [ \"rigel\", \"betelgeuse\" ], "
- "\"cygnus\": [ \"deneb\", \"albireo\"] } }";
+ "\"cygnus\": [ \"deneb\", \"albireo\"] } }";
testParser(txt, D2ParserContext::PARSER_JSON);
}
TEST(ParserTest, mapsInLists) {
string txt = "[ { \"body\": \"earth\", \"gravity\": 1.0 },"
- " { \"body\": \"mars\", \"gravity\": 0.376 } ]";
+ " { \"body\": \"mars\", \"gravity\": 0.376 } ]";
testParser(txt, D2ParserContext::PARSER_JSON);
}
" \"ncr-protocol\": \"UDP\", \n"
"# lots of comments here\n"
"# and here\n"
- "\"tsig-keys\": [], \n"
- "\"forward-ddns\" : {}, \n"
- "\"reverse-ddns\" : {} \n"
+ " \"tsig-keys\": [], \n"
+ " \"forward-ddns\" : {}, \n"
+ " \"reverse-ddns\" : {} \n"
"} \n"
"} \n";
testParser(txt, D2ParserContext::PARSER_DHCPDDNS);
" \"ip-address\": \"192.168.77.1\", \n"
" \"port\": 777, // this is a comment \n"
" \"ncr-protocol\": \"UDP\", // everything after // is ignored\n"
- "\"tsig-keys\": [], // this will be ignored, too\n"
- "\"forward-ddns\" : {}, \n"
- "\"reverse-ddns\" : {} \n"
+ " \"tsig-keys\": [], // this will be ignored, too\n"
+ " \"forward-ddns\" : {}, \n"
+ " \"reverse-ddns\" : {} \n"
"} \n"
"} \n";
testParser(txt, D2ParserContext::PARSER_DHCPDDNS, false);
" \"ip-address\": \"192.168.77.1\", \n"
" \"port\": 777, # this is a comment \n"
" \"ncr-protocol\": \"UDP\", # everything after # is ignored\n"
- "\"tsig-keys\": [], # this will be ignored, too\n"
- "\"forward-ddns\" : {}, \n"
- "\"reverse-ddns\" : {} \n"
+ " \"tsig-keys\": [], # this will be ignored, too\n"
+ " \"forward-ddns\" : {}, \n"
+ " \"reverse-ddns\" : {} \n"
"} \n"
"} \n";
testParser(txt, D2ParserContext::PARSER_DHCPDDNS, false);
" \"port\": 777, /* this is a C style comment\n"
"that\n can \n span \n multiple \n lines */ \n"
" \"ncr-protocol\": \"UDP\", \n"
- "\"tsig-keys\": [], \n"
- "\"forward-ddns\" : {}, \n"
- "\"reverse-ddns\" : {} \n"
+ " \"tsig-keys\": [], \n"
+ " \"forward-ddns\" : {}, \n"
+ " \"reverse-ddns\" : {} \n"
"} \n"
"} \n";
testParser(txt, D2ParserContext::PARSER_DHCPDDNS, false);
string txt =
"{ \"DhcpDdns\" : \n"
"{ \n"
- "\"comment\": \"a comment\",\n"
+ " \"comment\": \"a comment\",\n"
" \"ip-address\": \"192.168.77.1\", \n"
" \"port\": 777, \n "
" \"ncr-protocol\": \"UDP\", \n"
- "\"tsig-keys\" : [ { \n"
- " \"name\" : \"d2.md5.key\", \n"
- " \"user-context\" : { \"comment\" : \"indirect\" } } ], \n"
- "\"forward-ddns\" : {}, \n"
- "\"reverse-ddns\" : {}, \n"
- "\"user-context\": { \"compatible\": true }"
+ " \"tsig-keys\" : [ { \n"
+ " \"name\" : \"d2.md5.key\", \n"
+ " \"user-context\" : { \"comment\" : \"indirect\" } } ], \n"
+ " \"forward-ddns\" : {}, \n"
+ " \"reverse-ddns\" : {}, \n"
+ " \"user-context\": { \"compatible\": true }"
"} \n"
"} \n";
testParser(txt, D2ParserContext::PARSER_DHCPDDNS, false);
// Test that output-options is an alias of output_options.
TEST(ParserTest, outputDashOptions) {
- string txt=
+ string txt =
"{ \"DhcpDdns\" : \n"
"{ \n"
- "\"loggers\": [ {\n"
- " \"name\": \"kea-dhcp-ddns\",\n"
- " \"output-options\": [ { \"output\": \"stdout\" } ],\n"
- " \"severity\": \"INFO\" } ]\n"
- "} \n"
+ " \"loggers\": [ {\n"
+ " \"name\": \"kea-dhcp-ddns\",\n"
+ " \"output-options\": [ { \"output\": \"stdout\" } ],\n"
+ " \"severity\": \"INFO\" } ]\n"
+ "} \n"
"} \n";
testParser(txt, D2ParserContext::PARSER_DHCPDDNS, false);
}
TEST(ParserTest, listInList) {
string txt = "[ [ \"Britain\", \"Wales\", \"Scotland\" ], "
- "[ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
+ " [ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
testParser(txt, Parser4Context::PARSER_JSON);
}
TEST(ParserTest, listsInMaps) {
string txt = "{ \"constellations\": { \"orion\": [ \"rigel\", \"betelgeuse\" ], "
- "\"cygnus\": [ \"deneb\", \"albireo\"] } }";
+ "\"cygnus\": [ \"deneb\", \"albireo\"] } }";
testParser(txt, Parser4Context::PARSER_JSON);
}
TEST(ParserTest, mapsInLists) {
string txt = "[ { \"body\": \"earth\", \"gravity\": 1.0 },"
- " { \"body\": \"mars\", \"gravity\": 0.376 } ]";
+ " { \"body\": \"mars\", \"gravity\": 0.376 } ]";
testParser(txt, Parser4Context::PARSER_JSON);
}
TEST(ParserTest, keywordDhcp4) {
string txt = "{ \"Dhcp4\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"type\", \"htype\" ] },\n"
+ " \"interfaces\": [ \"type\", \"htype\" ] },\n"
"\"rebind-timer\": 2000, \n"
"\"renew-timer\": 1000, \n"
"\"subnet4\": [ { "
" \"id\": 1, "
" \"subnet\": \"192.0.2.0/24\", "
" \"interface\": \"test\" } ],\n"
- "\"valid-lifetime\": 4000 } }";
+ "\"valid-lifetime\": 4000 } }";
testParser(txt, Parser4Context::PARSER_DHCP4);
}
// Tests if bash (#) comments are supported. That's the only comment type that
// was supported by the old parser.
TEST(ParserTest, bashComments) {
- string txt= "{ \"Dhcp4\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"*\" ]"
- "},\n"
- "# this is a comment\n"
- "\"rebind-timer\": 2000, \n"
- "# lots of comments here\n"
- "# and here\n"
- "\"renew-timer\": 1000, \n"
- "\"subnet4\": [ { "
- " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
- " \"id\": 1, "
- " \"subnet\": \"192.0.2.0/24\", "
- " \"interface\": \"eth0\""
- " } ],"
- "\"valid-lifetime\": 4000 } }";
+ string txt = "{ \"Dhcp4\": { \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},\n"
+ "# this is a comment\n"
+ "\"rebind-timer\": 2000, \n"
+ "# lots of comments here\n"
+ "# and here\n"
+ "\"renew-timer\": 1000, \n"
+ "\"subnet4\": [ { "
+ " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
+ " \"id\": 1, "
+ " \"subnet\": \"192.0.2.0/24\", "
+ " \"interface\": \"eth0\""
+ " } ],"
+ "\"valid-lifetime\": 4000 } }";
testParser(txt, Parser4Context::PARSER_DHCP4, false);
}
// Tests if C++ (//) comments can start anywhere, not just in the first line.
TEST(ParserTest, cppComments) {
- string txt= "{ \"Dhcp4\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"*\" ]"
- "},\n"
- "\"rebind-timer\": 2000, // everything after // is ignored\n"
- "\"renew-timer\": 1000, // this will be ignored, too\n"
- "\"subnet4\": [ { "
- " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
- " \"id\": 1, "
- " \"subnet\": \"192.0.2.0/24\", "
- " \"interface\": \"eth0\""
- " } ],"
- "\"valid-lifetime\": 4000 } }";
+ string txt = "{ \"Dhcp4\": { \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},\n"
+ "\"rebind-timer\": 2000, // everything after // is ignored\n"
+ "\"renew-timer\": 1000, // this will be ignored, too\n"
+ "\"subnet4\": [ { "
+ " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
+ " \"id\": 1, "
+ " \"subnet\": \"192.0.2.0/24\", "
+ " \"interface\": \"eth0\""
+ " } ],"
+ "\"valid-lifetime\": 4000 } }";
testParser(txt, Parser4Context::PARSER_DHCP4, false);
}
// Tests if bash (#) comments can start anywhere, not just in the first line.
TEST(ParserTest, bashCommentsInline) {
- string txt= "{ \"Dhcp4\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"*\" ]"
- "},\n"
- "\"rebind-timer\": 2000, # everything after # is ignored\n"
- "\"renew-timer\": 1000, # this will be ignored, too\n"
- "\"subnet4\": [ { "
- " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
- " \"id\": 1, "
- " \"subnet\": \"192.0.2.0/24\", "
- " \"interface\": \"eth0\""
- " } ],"
- "\"valid-lifetime\": 4000 } }";
+ string txt = "{ \"Dhcp4\": { \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},\n"
+ "\"rebind-timer\": 2000, # everything after # is ignored\n"
+ "\"renew-timer\": 1000, # this will be ignored, too\n"
+ "\"subnet4\": [ { "
+ " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
+ " \"id\": 1, "
+ " \"subnet\": \"192.0.2.0/24\", "
+ " \"interface\": \"eth0\""
+ " } ],"
+ "\"valid-lifetime\": 4000 } }";
testParser(txt, Parser4Context::PARSER_DHCP4, false);
}
// Tests if multi-line C style comments are handled correctly.
TEST(ParserTest, multilineComments) {
- string txt= "{ \"Dhcp4\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"*\" ]"
- "},\n"
- " /* this is a C style comment\n"
- "that\n can \n span \n multiple \n lines */ \n"
- "\"rebind-timer\": 2000,\n"
- "\"renew-timer\": 1000, \n"
- "\"subnet4\": [ { "
- " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
- " \"id\": 1, "
- " \"subnet\": \"192.0.2.0/24\", "
- " \"interface\": \"eth0\""
- " } ],"
- "\"valid-lifetime\": 4000 } }";
+ string txt = "{ \"Dhcp4\": { \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},\n"
+ " /* this is a C style comment\n"
+ "that\n can \n span \n multiple \n lines */ \n"
+ "\"rebind-timer\": 2000,\n"
+ "\"renew-timer\": 1000, \n"
+ "\"subnet4\": [ { "
+ " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
+ " \"id\": 1, "
+ " \"subnet\": \"192.0.2.0/24\", "
+ " \"interface\": \"eth0\""
+ " } ],"
+ "\"valid-lifetime\": 4000 } }";
testParser(txt, Parser4Context::PARSER_DHCP4, false);
}
// Tests if embedded comments are handled correctly.
TEST(ParserTest, embbededComments) {
- string txt= "{ \"Dhcp4\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"*\" ]"
- "},\n"
- "\"comment\": \"a comment\",\n"
- "\"rebind-timer\": 2000,\n"
- "\"renew-timer\": 1000, \n"
- "\"subnet4\": [ { "
- " \"user-context\": { \"comment\": \"indirect\" },"
- " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
- " \"id\": 1, "
- " \"subnet\": \"192.0.2.0/24\", "
- " \"interface\": \"eth0\""
- " } ],"
- "\"user-context\": { \"compatible\": true },"
- "\"valid-lifetime\": 4000 } }";
+ string txt = "{ \"Dhcp4\": { \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},\n"
+ "\"comment\": \"a comment\",\n"
+ "\"rebind-timer\": 2000,\n"
+ "\"renew-timer\": 1000, \n"
+ "\"subnet4\": [ { "
+ " \"user-context\": { \"comment\": \"indirect\" },"
+ " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
+ " \"id\": 1, "
+ " \"subnet\": \"192.0.2.0/24\", "
+ " \"interface\": \"eth0\""
+ " } ],"
+ "\"user-context\": { \"compatible\": true },"
+ "\"valid-lifetime\": 4000 } }";
testParser(txt, Parser4Context::PARSER_DHCP4, false);
}
// Test that output-options is an alias of output_options.
TEST(ParserTest, outputDashOptions) {
- string txt= "{ \"Dhcp4\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"*\" ]"
- "},\n"
- "\"rebind-timer\": 2000,\n"
- "\"renew-timer\": 1000, \n"
- "\"valid-lifetime\": 4000,\n"
- "\"loggers\": [ { "
- " \"name\": \"kea-dhcp4\","
- " \"output-options\": [ { \"output\": \"stdout\" } ],"
- " \"severity\": \"INFO\" } ]\n"
- "} }";
+ string txt = "{ \"Dhcp4\": { \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},\n"
+ "\"rebind-timer\": 2000,\n"
+ "\"renew-timer\": 1000, \n"
+ "\"valid-lifetime\": 4000,\n"
+ "\"loggers\": [ { "
+ " \"name\": \"kea-dhcp4\","
+ " \"output-options\": [ { \"output\": \"stdout\" } ],"
+ " \"severity\": \"INFO\" } ]\n"
+ "} }";
testParser(txt, Parser4Context::PARSER_DHCP4, false);
}
TEST(ParserTest, listInList) {
string txt = "[ [ \"Britain\", \"Wales\", \"Scotland\" ], "
- "[ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
+ " [ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
testParser(txt, Parser6Context::PARSER_JSON);
}
TEST(ParserTest, listsInMaps) {
string txt = "{ \"constellations\": { \"orion\": [ \"rigel\", \"betelgeuse\" ], "
- "\"cygnus\": [ \"deneb\", \"albireo\"] } }";
+ "\"cygnus\": [ \"deneb\", \"albireo\"] } }";
testParser(txt, Parser6Context::PARSER_JSON);
}
TEST(ParserTest, mapsInLists) {
string txt = "[ { \"body\": \"earth\", \"gravity\": 1.0 },"
- " { \"body\": \"mars\", \"gravity\": 0.376 } ]";
+ " { \"body\": \"mars\", \"gravity\": 0.376 } ]";
testParser(txt, Parser6Context::PARSER_JSON);
}
TEST(ParserTest, keywordDhcp6) {
string txt = "{ \"Dhcp6\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"type\", \"htype\" ] },\n"
+ " \"interfaces\": [ \"type\", \"htype\" ] },\n"
"\"preferred-lifetime\": 3000,\n"
"\"rebind-timer\": 2000, \n"
"\"renew-timer\": 1000, \n"
" \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
" \"subnet\": \"2001:db8:1::/48\", "
" \"interface\": \"test\" } ],\n"
- "\"valid-lifetime\": 4000 } }";
+ "\"valid-lifetime\": 4000 } }";
testParser(txt, Parser6Context::PARSER_DHCP6);
}
// Tests if bash (#) comments are supported. That's the only comment type that
// was supported by the old parser.
TEST(ParserTest, bashComments) {
- string txt= "{ \"Dhcp6\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"*\" ]"
- "},\n"
- "\"preferred-lifetime\": 3000,\n"
- "# this is a comment\n"
- "\"rebind-timer\": 2000, \n"
- "# lots of comments here\n"
- "# and here\n"
- "\"renew-timer\": 1000, \n"
- "\"subnet6\": [ { "
- " \"id\": 1, "
- " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
- " \"subnet\": \"2001:db8:1::/48\", "
- " \"interface\": \"eth0\""
- " } ],"
- "\"valid-lifetime\": 4000 } }";
+ string txt = "{ \"Dhcp6\": { \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},\n"
+ "\"preferred-lifetime\": 3000,\n"
+ "# this is a comment\n"
+ "\"rebind-timer\": 2000, \n"
+ "# lots of comments here\n"
+ "# and here\n"
+ "\"renew-timer\": 1000, \n"
+ "\"subnet6\": [ { "
+ " \"id\": 1, "
+ " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
+ " \"subnet\": \"2001:db8:1::/48\", "
+ " \"interface\": \"eth0\""
+ " } ],"
+ "\"valid-lifetime\": 4000 } }";
testParser(txt, Parser6Context::PARSER_DHCP6);
}
// Tests if C++ (//) comments can start anywhere, not just in the first line.
TEST(ParserTest, cppComments) {
- string txt= "{ \"Dhcp6\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"*\" ]"
- "},\n"
- "\"preferred-lifetime\": 3000, // this is a comment \n"
- "\"rebind-timer\": 2000, // everything after // is ignored\n"
- "\"renew-timer\": 1000, // this will be ignored, too\n"
- "\"subnet6\": [ { "
- " \"id\": 1, "
- " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
- " \"subnet\": \"2001:db8:1::/48\", "
- " \"interface\": \"eth0\""
- " } ],"
- "\"valid-lifetime\": 4000 } }";
+ string txt = "{ \"Dhcp6\": { \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},\n"
+ "\"preferred-lifetime\": 3000, // this is a comment \n"
+ "\"rebind-timer\": 2000, // everything after // is ignored\n"
+ "\"renew-timer\": 1000, // this will be ignored, too\n"
+ "\"subnet6\": [ { "
+ " \"id\": 1, "
+ " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
+ " \"subnet\": \"2001:db8:1::/48\", "
+ " \"interface\": \"eth0\""
+ " } ],"
+ "\"valid-lifetime\": 4000 } }";
testParser(txt, Parser6Context::PARSER_DHCP6, false);
}
// Tests if bash (#) comments can start anywhere, not just in the first line.
TEST(ParserTest, bashCommentsInline) {
- string txt= "{ \"Dhcp6\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"*\" ]"
- "},\n"
- "\"preferred-lifetime\": 3000, # this is a comment \n"
- "\"rebind-timer\": 2000, # everything after # is ignored\n"
- "\"renew-timer\": 1000, # this will be ignored, too\n"
- "\"subnet6\": [ { "
- " \"id\": 1, "
- " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
- " \"subnet\": \"2001:db8:1::/48\", "
- " \"interface\": \"eth0\""
- " } ],"
- "\"valid-lifetime\": 4000 } }";
+ string txt = "{ \"Dhcp6\": { \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},\n"
+ "\"preferred-lifetime\": 3000, # this is a comment \n"
+ "\"rebind-timer\": 2000, # everything after # is ignored\n"
+ "\"renew-timer\": 1000, # this will be ignored, too\n"
+ "\"subnet6\": [ { "
+ " \"id\": 1, "
+ " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
+ " \"subnet\": \"2001:db8:1::/48\", "
+ " \"interface\": \"eth0\""
+ " } ],"
+ "\"valid-lifetime\": 4000 } }";
testParser(txt, Parser6Context::PARSER_DHCP6, false);
}
// Tests if multi-line C style comments are handled correctly.
TEST(ParserTest, multilineComments) {
- string txt= "{ \"Dhcp6\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"*\" ]"
- "},\n"
- "\"preferred-lifetime\": 3000, /* this is a C style comment\n"
- "that\n can \n span \n multiple \n lines */ \n"
- "\"rebind-timer\": 2000,\n"
- "\"renew-timer\": 1000, \n"
- "\"subnet6\": [ { "
- " \"id\": 1, "
- " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
- " \"subnet\": \"2001:db8:1::/48\", "
- " \"interface\": \"eth0\""
- " } ],"
- "\"valid-lifetime\": 4000 } }";
+ string txt = "{ \"Dhcp6\": { \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},\n"
+ "\"preferred-lifetime\": 3000, /* this is a C style comment\n"
+ "that\n can \n span \n multiple \n lines */ \n"
+ "\"rebind-timer\": 2000,\n"
+ "\"renew-timer\": 1000, \n"
+ "\"subnet6\": [ { "
+ " \"id\": 1, "
+ " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
+ " \"subnet\": \"2001:db8:1::/48\", "
+ " \"interface\": \"eth0\""
+ " } ],"
+ "\"valid-lifetime\": 4000 } }";
testParser(txt, Parser6Context::PARSER_DHCP6, false);
}
// Tests if embedded comments are handled correctly.
TEST(ParserTest, embbededComments) {
- string txt= "{ \"Dhcp6\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"*\" ]"
- "},\n"
- "\"comment\": \"a comment\",\n"
- "\"preferred-lifetime\": 3000,\n"
- "\"rebind-timer\": 2000,\n"
- "\"renew-timer\": 1000, \n"
- "\"subnet6\": [ { "
- " \"id\": 1, "
- " \"user-context\": { \"comment\": \"indirect\" },"
- " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
- " \"subnet\": \"2001:db8:1::/48\", "
- " \"interface\": \"eth0\""
- " } ],"
- "\"user-context\": { \"compatible\": true },"
- "\"valid-lifetime\": 4000 } }";
+ string txt = "{ \"Dhcp6\": { \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},\n"
+ "\"comment\": \"a comment\",\n"
+ "\"preferred-lifetime\": 3000,\n"
+ "\"rebind-timer\": 2000,\n"
+ "\"renew-timer\": 1000, \n"
+ "\"subnet6\": [ { "
+ " \"id\": 1, "
+ " \"user-context\": { \"comment\": \"indirect\" },"
+ " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
+ " \"subnet\": \"2001:db8:1::/48\", "
+ " \"interface\": \"eth0\""
+ " } ],"
+ "\"user-context\": { \"compatible\": true },"
+ "\"valid-lifetime\": 4000 } }";
testParser(txt, Parser6Context::PARSER_DHCP6, false);
}
// Test that output-options is an alias of output_options.
TEST(ParserTest, outputDashOptions) {
- string txt= "{ \"Dhcp6\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"*\" ]"
- "},\n"
- "\"preferred-lifetime\": 3000,\n"
- "\"rebind-timer\": 2000,\n"
- "\"renew-timer\": 1000, \n"
- "\"valid-lifetime\": 4000,\n"
- "\"loggers\": [ { "
- " \"name\": \"kea-dhcp6\","
- " \"output-options\": [ { \"output\": \"stdout\" } ],"
- " \"severity\": \"INFO\" } ]\n"
- "} }";
+ string txt = "{ \"Dhcp6\": { \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},\n"
+ "\"preferred-lifetime\": 3000,\n"
+ "\"rebind-timer\": 2000,\n"
+ "\"renew-timer\": 1000, \n"
+ "\"valid-lifetime\": 4000,\n"
+ "\"loggers\": [ { "
+ " \"name\": \"kea-dhcp6\","
+ " \"output-options\": [ { \"output\": \"stdout\" } ],"
+ " \"severity\": \"INFO\" } ]\n"
+ "} }";
testParser(txt, Parser6Context::PARSER_DHCP6, false);
}
TEST(ParserTest, listInList) {
string txt = "[ [ \"Britain\", \"Wales\", \"Scotland\" ], "
- "[ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
+ " [ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
testParser(txt, ParserContext::PARSER_JSON);
}
TEST(ParserTest, listsInMaps) {
string txt = "{ \"constellations\": { \"orion\": [ \"rigel\", \"betelgeuse\" ], "
- "\"cygnus\": [ \"deneb\", \"albireo\"] } }";
+ "\"cygnus\": [ \"deneb\", \"albireo\"] } }";
testParser(txt, ParserContext::PARSER_JSON);
}
TEST(ParserTest, mapsInLists) {
string txt = "[ { \"body\": \"earth\", \"gravity\": 1.0 },"
- " { \"body\": \"mars\", \"gravity\": 0.376 } ]";
+ " { \"body\": \"mars\", \"gravity\": 0.376 } ]";
testParser(txt, ParserContext::PARSER_JSON);
}
" }"
" ]"
"}";
-
// This is only a subset of full config, so we'll parse with PARSER_SUB_NETCONF.
testParser(txt, ParserContext::PARSER_SUB_NETCONF);
testParser(txt, ParserContext::PARSER_JSON);
string txt= "{ \"Netconf\": {"
" \"managed-servers\": {\n"
" \"d2\": {\n"
- " \"model\": \"foo\",\n"
- " \"control-socket\": {\n"
+ " \"model\": \"foo\",\n"
+ " \"control-socket\": {\n"
"# this is a comment\n"
- "\"socket-type\": \"unix\", \n"
+ " \"socket-type\": \"unix\", \n"
"# This socket is mine. I can name it whatever\n"
"# I like, ok?\n"
- "\"socket-name\": \"Hector\" \n"
+ " \"socket-name\": \"Hector\" \n"
"} } } } }";
testParser(txt, ParserContext::PARSER_NETCONF);
}
" // Let's try talking to D2. Sadly, it never talks"
" // to us back :( Maybe he doesn't like his name?\n"
" \"d2\": {\n"
- " \"model\": \"foo\",\n"
- " \"control-socket\": {\n"
- "\"socket-type\": \"unix\", \n"
- "\"socket-name\": \"Hector\" \n"
+ " \"model\": \"foo\",\n"
+ " \"control-socket\": {\n"
+ " \"socket-type\": \"unix\", \n"
+ " \"socket-name\": \"Hector\" \n"
"} } } } }";
-
testParser(txt, ParserContext::PARSER_NETCONF, false);
}
string txt= "{ \"Netconf\": {"
" \"managed-servers\": {\n"
" \"d2\": {\n"
- " \"model\": \"foo\",\n"
- " \"control-socket\": {\n"
- "\"socket-type\": \"unix\", # Maybe Hector is not really a \n"
- "\"socket-name\": \"Hector\" # Unix process?\n"
+ " \"model\": \"foo\",\n"
+ " \"control-socket\": {\n"
+ " \"socket-type\": \"unix\", # Maybe Hector is not really a \n"
+ " \"socket-name\": \"Hector\" # Unix process?\n"
"# Oh no! He's a windows one and just pretending!\n"
"} } } } }";
testParser(txt, ParserContext::PARSER_NETCONF, false);
" /* Ok, forget about it. If Hector doesn't want to talk,\n"
" we won't talk to him either. We now have quiet days. */\n"
" /* \"d2\": {"
- " \"model\": \"bar\",\n"
- " \"control-socket\": {\n"
- " \"socket-type\": \"unix\",\n"
- "\"socket-name\": \"Hector\"\n"
+ " \"model\": \"bar\",\n"
+ " \"control-socket\": {\n"
+ " \"socket-type\": \"unix\",\n"
+ " \"socket-name\": \"Hector\"\n"
"} }*/ } } }";
testParser(txt, ParserContext::PARSER_NETCONF, false);
}
" \"comment\": \"a comment\","
" \"managed-servers\": {\n"
" \"dhcp4\": {\n"
- " \"control-socket\": {\n"
- " \"user-context\": { \"comment\": \"indirect\" },\n"
- " \"socket-type\": \"stdout\"\n"
+ " \"control-socket\": {\n"
+ " \"user-context\": { \"comment\": \"indirect\" },\n"
+ " \"socket-type\": \"stdout\"\n"
" } } },\n"
" \"user-context\": { \"compatible\": true }\n"
"} }";
"single-subnet.json",
"vendor-specific.json",
"vivso.json",
- "with-ddns.json",
+ //"with-ddns.json",
};
for (string file : examples) {
resetSession();
"softwire46.json",
"stateless.json",
"tee-times.json",
- "with-ddns.json",
+ //"with-ddns.json",
};
for (string file : examples) {
resetSession();