summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrancis Dupont <fdupont@isc.org>2016-11-21 13:31:04 +0100
committerTomek Mrugalski <tomasz@isc.org>2016-11-29 19:57:33 +0100
commit340bc94d225d7214364adc94bc44ec8d9409a474 (patch)
tree2d5333edfabeea7d40b18d4ee7f664cec3aa0367 /src
parent[5014] Syntactic contexts almost done (diff)
downloadkea-340bc94d225d7214364adc94bc44ec8d9409a474.tar.xz
kea-340bc94d225d7214364adc94bc44ec8d9409a474.zip
[5014] Added 2 unit tests about keywords
Diffstat (limited to 'src')
-rw-r--r--src/bin/dhcp6/dhcp6.dox26
-rw-r--r--src/bin/dhcp6/parser_context.h4
-rw-r--r--src/bin/dhcp6/tests/parser_unittest.cc22
3 files changed, 37 insertions, 15 deletions
diff --git a/src/bin/dhcp6/dhcp6.dox b/src/bin/dhcp6/dhcp6.dox
index 1d29bf012d..a7a5885e9d 100644
--- a/src/bin/dhcp6/dhcp6.dox
+++ b/src/bin/dhcp6/dhcp6.dox
@@ -84,10 +84,10 @@ general, the following issues of the existing code were noted:
having trailing commas:
@code
"option-data": [
- {
- "code": 12,
- "data": "2001:db8:1:0:ff00::1"
- },
+ {
+ "code": 12,
+ "data": "2001:db8:1:0:ff00::1"
+ },
]
@endcode
or having incorrect types, e.g. specifying timer values as strings.
@@ -295,16 +295,16 @@ isc::dhcp::Triplet<uint32_t>
SubnetConfigParser::getParam(const std::string& name) {
uint32_t value = 0;
try {
- // look for local value
- value = uint32_values_->getParam(name);
+ // look for local value
+ value = uint32_values_->getParam(name);
} catch (const DhcpConfigError &) {
- try {
- // no local, use global value
- value = global_context_->uint32_values_->getParam(name);
- } catch (const DhcpConfigError &) {
- isc_throw(DhcpConfigError, "Mandatory parameter " << name
- << " missing (no global default and no subnet-"
- << "specific value)");
+ try {
+ // no local, use global value
+ value = global_context_->uint32_values_->getParam(name);
+ } catch (const DhcpConfigError &) {
+ isc_throw(DhcpConfigError, "Mandatory parameter " << name
+ << " missing (no global default and no subnet-"
+ << "specific value)");
}
}
diff --git a/src/bin/dhcp6/parser_context.h b/src/bin/dhcp6/parser_context.h
index 22bc6b3161..e3a4f1d4ee 100644
--- a/src/bin/dhcp6/parser_context.h
+++ b/src/bin/dhcp6/parser_context.h
@@ -120,8 +120,8 @@ public:
POOLS,
PD_POOLS,
RESERVATIONS,
- /// client-classes
- CLIENT_CLASS,
+ /// client-classes
+ CLIENT_CLASS,
/// Logging
LOGGERS,
/// loggers
diff --git a/src/bin/dhcp6/tests/parser_unittest.cc b/src/bin/dhcp6/tests/parser_unittest.cc
index 7e12155d84..e8ffbbccc7 100644
--- a/src/bin/dhcp6/tests/parser_unittest.cc
+++ b/src/bin/dhcp6/tests/parser_unittest.cc
@@ -106,6 +106,28 @@ TEST(ParserTest, types) {
testParser(txt, Parser6Context::PARSER_GENERIC_JSON);
}
+TEST(ParserTest, keywordJSON) {
+ string txt = "{ \"name\": \"user\","
+ "\"type\": \"password\","
+ "\"user\": \"name\","
+ "\"password\": \"type\" }";
+ testParser(txt, Parser6Context::PARSER_GENERIC_JSON);
+}
+
+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 } }";
+ testParser2(txt, Parser6Context::PARSER_DHCP6);
+}
+
TEST(ParserTest, bashComments) {
string txt= "{ \"Dhcp6\": { \"interfaces-config\": {"
" \"interfaces\": [ \"*\" ]"