Browse Source

[4096] Added unit test for an blank client class name

Thomas Markwalder 9 years ago
parent
commit
ca10116a5d
1 changed files with 25 additions and 1 deletions
  1. 25 1
      src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc

+ 25 - 1
src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc

@@ -370,7 +370,7 @@ TEST_F(ClientClassDefParserTest, noClassName) {
 
 
     std::string cfg_text =
     std::string cfg_text =
         "{ \n"
         "{ \n"
-        "    \"test\": \"vendor-class-identifier == 'MSFT'\", \n"
+        "    \"test\": \"option[123] == 'abc'\", \n"
         "    \"option-data\": [ \n"
         "    \"option-data\": [ \n"
         "        { \n"
         "        { \n"
         "           \"name\": \"domain-name-servers\", \n"
         "           \"name\": \"domain-name-servers\", \n"
@@ -387,6 +387,30 @@ TEST_F(ClientClassDefParserTest, noClassName) {
                  DhcpConfigError);
                  DhcpConfigError);
 }
 }
 
 
+// Verifies that a class with a blank name, fails to parse.
+TEST_F(ClientClassDefParserTest, blankClassName) {
+
+    std::string cfg_text =
+        "{ \n"
+        "    \"name\": \"\", \n"
+        "    \"test\": \"option[123] == 'abc'\", \n"
+        "    \"option-data\": [ \n"
+        "        { \n"
+        "           \"name\": \"domain-name-servers\", \n"
+        "           \"code\": 6, \n"
+        "           \"space\": \"dhcp4\", \n"
+        "           \"csv-format\": true, \n"
+        "           \"data\": \"192.0.2.1, 192.0.2.2\" \n"
+        "        } \n"
+        "      ] \n"
+        "} \n";
+
+    ClientClassDefPtr cclass;
+    ASSERT_THROW(cclass = parseClientClassDef(cfg_text, Option::V4),
+                 DhcpConfigError);
+}
+
+
 // Verifies that a class with an unknown element, fails to parse.
 // Verifies that a class with an unknown element, fails to parse.
 TEST_F(ClientClassDefParserTest, unknownElement) {
 TEST_F(ClientClassDefParserTest, unknownElement) {
     std::string cfg_text =
     std::string cfg_text =