Browse Source

[5297] Addressed extras

Francis Dupont 7 years ago
parent
commit
4f6aead24f

+ 1 - 0
src/lib/dhcpsrv/parsers/dhcp_parsers.cc

@@ -915,6 +915,7 @@ Subnet6ConfigParser::parse(ConstElementPtr subnet) {
     return (sn6ptr);
 }
 
+// Unused?
 void
 Subnet6ConfigParser::duplicate_option_warning(uint32_t code,
                                               asiolink::IOAddress& addr) {

+ 1 - 0
src/lib/dhcpsrv/parsers/duid_config_parser.cc

@@ -27,6 +27,7 @@ void
 DUIDConfigParser::parse(const CfgDUIDPtr& cfg,
                         isc::data::ConstElementPtr duid_configuration) {
     if (!cfg) {
+        // Sanity check
         isc_throw(DhcpConfigError, "Must provide valid pointer to cfg when parsing duid");
     }
 

+ 1 - 0
src/lib/dhcpsrv/parsers/option_data_parser.cc

@@ -36,6 +36,7 @@ OptionDataParser::parse(isc::data::ConstElementPtr single_option) {
     std::pair<OptionDescriptor, std::string> opt = createOption(single_option);
 
     if (!opt.first.option_) {
+        // Should never happen (@todo: update message)
         isc_throw(isc::InvalidOperation,
             "parser logic error: no option has been configured and"
             " thus there is nothing to commit. Has build() been called?");

+ 17 - 0
src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc

@@ -779,6 +779,23 @@ TEST_F(ParseConfigTest, minimalOptionDataTest) {
     cfg.runCfgOptionsTest(family_, expected);
 }
 
+/// @brief Check parsing of unknown options fails.
+TEST_F(ParseConfigTest, unknownOptionDataTest) {
+
+    // Configuration string.
+    std::string config =
+        "{ \"option-data\": [ {"
+        "    \"name\": \"foo\","
+        "    \"data\": \"01\","
+        "    \"space\": \"bar\""
+        " } ]"
+        "}";
+
+    // Verify that the configuration string does not parse.
+    int rcode = parseConfiguration(config, true);
+    ASSERT_NE(0, rcode);
+}
+
 /// @brief Check parsing of options with invalid space fails.
 TEST_F(ParseConfigTest, badSpaceOptionDataTest) {