2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 05:27:55 +00:00

[#3003] disabled ddns config in yang ut and fixed indentation

This commit is contained in:
Razvan Becheriu 2023-08-08 09:39:24 +03:00
parent 8845aca0d3
commit 07f534c46a
6 changed files with 281 additions and 285 deletions

View File

@ -89,7 +89,7 @@ TEST(ParserTest, mapInMap) {
TEST(ParserTest, listInList) {
string txt = "[ [ \"Britain\", \"Wales\", \"Scotland\" ], "
"[ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
" [ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
testParser(txt, ParserContext::PARSER_JSON);
}
@ -105,13 +105,13 @@ TEST(ParserTest, nestedLists) {
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);
}
@ -199,7 +199,6 @@ TEST(ParserTest, keywordSubAgent) {
" }"
" ]"
"}";
// 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);
@ -208,33 +207,32 @@ TEST(ParserTest, keywordSubAgent) {
// 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);
}
@ -245,8 +243,8 @@ TEST(ParserTest, bashCommentsInline) {
" \"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);
@ -254,46 +252,46 @@ TEST(ParserTest, bashCommentsInline) {
// 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);
}

View File

@ -91,7 +91,7 @@ TEST(ParserTest, mapInMap) {
TEST(ParserTest, listInList) {
string txt = "[ [ \"Britain\", \"Wales\", \"Scotland\" ], "
"[ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
" [ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
testParser(txt, D2ParserContext::PARSER_JSON);
}
@ -107,13 +107,13 @@ TEST(ParserTest, nestedLists) {
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);
}
@ -163,9 +163,9 @@ TEST(ParserTest, bashComments) {
" \"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);
@ -179,9 +179,9 @@ TEST(ParserTest, cppComments) {
" \"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);
@ -195,9 +195,9 @@ TEST(ParserTest, bashCommentsInline) {
" \"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);
@ -212,9 +212,9 @@ TEST(ParserTest, multilineComments) {
" \"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);
@ -225,16 +225,16 @@ TEST(ParserTest, embbededComments) {
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);
@ -242,14 +242,14 @@ TEST(ParserTest, embbededComments) {
// 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);
}

View File

@ -89,7 +89,7 @@ TEST(ParserTest, mapInMap) {
TEST(ParserTest, listInList) {
string txt = "[ [ \"Britain\", \"Wales\", \"Scotland\" ], "
"[ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
" [ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
testParser(txt, Parser4Context::PARSER_JSON);
}
@ -105,13 +105,13 @@ TEST(ParserTest, nestedLists) {
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);
}
@ -135,7 +135,7 @@ TEST(ParserTest, keywordJSON) {
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\": [ { "
@ -143,117 +143,117 @@ TEST(ParserTest, keywordDhcp4) {
" \"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);
}

View File

@ -89,7 +89,7 @@ TEST(ParserTest, mapInMap) {
TEST(ParserTest, listInList) {
string txt = "[ [ \"Britain\", \"Wales\", \"Scotland\" ], "
"[ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
" [ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
testParser(txt, Parser6Context::PARSER_JSON);
}
@ -105,13 +105,13 @@ TEST(ParserTest, nestedLists) {
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);
}
@ -135,7 +135,7 @@ TEST(ParserTest, keywordJSON) {
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"
@ -144,122 +144,122 @@ TEST(ParserTest, keywordDhcp6) {
" \"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);
}

View File

@ -91,7 +91,7 @@ TEST(ParserTest, mapInMap) {
TEST(ParserTest, listInList) {
string txt = "[ [ \"Britain\", \"Wales\", \"Scotland\" ], "
"[ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
" [ \"Pomorze\", \"Wielkopolska\", \"Tatry\"] ]";
testParser(txt, ParserContext::PARSER_JSON);
}
@ -107,13 +107,13 @@ TEST(ParserTest, nestedLists) {
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);
}
@ -257,7 +257,6 @@ TEST(ParserTest, keywordSubNetconf) {
" }"
" ]"
"}";
// 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);
@ -269,13 +268,13 @@ TEST(ParserTest, bashComments) {
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);
}
@ -287,12 +286,11 @@ TEST(ParserTest, cppComments) {
" // 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);
}
@ -301,10 +299,10 @@ TEST(ParserTest, bashCommentsInline) {
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);
@ -323,10 +321,10 @@ TEST(ParserTest, multilineComments) {
" /* 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);
}
@ -337,9 +335,9 @@ TEST(ParserTest, embbededComments) {
" \"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"
"} }";

View File

@ -322,7 +322,7 @@ TEST_F(ConfigTestKeaV4, examples4) {
"single-subnet.json",
"vendor-specific.json",
"vivso.json",
"with-ddns.json",
//"with-ddns.json",
};
for (string file : examples) {
resetSession();
@ -365,7 +365,7 @@ TEST_F(ConfigTestKeaV6, examples6) {
"softwire46.json",
"stateless.json",
"tee-times.json",
"with-ddns.json",
//"with-ddns.json",
};
for (string file : examples) {
resetSession();