]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5014] Added 2 unit tests about keywords
authorFrancis Dupont <fdupont@isc.org>
Mon, 21 Nov 2016 12:31:04 +0000 (13:31 +0100)
committerFrancis Dupont <fdupont@isc.org>
Mon, 21 Nov 2016 12:31:04 +0000 (13:31 +0100)
src/bin/dhcp6/dhcp6.dox
src/bin/dhcp6/parser_context.h
src/bin/dhcp6/tests/parser_unittest.cc

index 1d29bf012d55020ed403707ab2c154cab497a3a6..a7a5885e9d2a6980705dce767870a89ba42a26b7 100644 (file)
@@ -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)");
        }
     }
 
index 22bc6b3161bc1f9ee4b23d76ddd92cbab2afa9f7..e3a4f1d4ee1b00cc7bb50169f8e9366231c6d9f2 100644 (file)
@@ -120,8 +120,8 @@ public:
         POOLS,
         PD_POOLS,
         RESERVATIONS,
-       /// client-classes
-       CLIENT_CLASS,
+        /// client-classes
+        CLIENT_CLASS,
         /// Logging
         LOGGERS,
         /// loggers
index 7e12155d847cc0dacb22f05072c3014b18d2b4c9..e8ffbbccc752d282dc8fa5059e0192395ea2abe0 100644 (file)
@@ -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\": [ \"*\" ]"