]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5680] Added unit tests to verify kea-dhcp6 santizes FQDN values
authorThomas Markwalder <tmark@isc.org>
Thu, 19 Jul 2018 20:06:29 +0000 (16:06 -0400)
committerTomek Mrugalski <tomasz@isc.org>
Fri, 27 Jul 2018 11:54:10 +0000 (13:54 +0200)
modified:   src/bin/dhcp6/tests/fqdn_unittest.cc

src/bin/dhcp6/tests/fqdn_unittest.cc

index 17b8da438af8f6bbd2ffc848955e7e860531f6c1..4ed958c38a982ef276ec8433704c600f4912039e 100644 (file)
@@ -129,7 +129,7 @@ public:
                                   ((mask & REPLACE_CLIENT_NAME) ?
                                    D2ClientConfig::RCM_WHEN_PRESENT
                                    : D2ClientConfig::RCM_NEVER),
-                                  "myhost", "example.com", "", "")));
+                                  "myhost", "example.com", "[^A-Za-z0-9-]", "x")));
         ASSERT_NO_THROW(CfgMgr::instance().setD2ClientConfig(cfg));
         ASSERT_NO_THROW(srv_->startD2());
     }
@@ -1517,4 +1517,33 @@ TEST_F(FqdnDhcpv6SrvTest, replaceClientNameModeTest) {
                               CLIENT_NAME_PRESENT, NAME_NOT_REPLACED);
 }
 
+
+// Verifies that setting hostname-char-set sanitizes FQDN option
+// values received from clients.
+TEST_F(FqdnDhcpv6SrvTest, sanitizeFqdn) {
+    // Verify a full FQDN with no invalid chars is left alone
+    testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_S,
+             "myhost.example.com",
+             Option6ClientFqdn::FULL, Option6ClientFqdn::FLAG_S,
+             "myhost.example.com.", false);
+
+    // Verify that a partial FQDN with no invalid chars is left alone
+    testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_S,
+             "myhost",
+             Option6ClientFqdn::PARTIAL, Option6ClientFqdn::FLAG_S,
+             "myhost.example.com.", false);
+
+    // Verify that a full FQDN with invalid chars is cleaned.
+    testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_S,
+             "m%y*host.example.com",
+             Option6ClientFqdn::FULL, Option6ClientFqdn::FLAG_S,
+             "mxyxhost.example.com.", false);
+
+    // Verify that a partial FQDN with invalid chars is cleaned.
+    testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_S,
+             "m%y*host",
+             Option6ClientFqdn::PARTIAL, Option6ClientFqdn::FLAG_S,
+             "mxyxhost.example.com.", false);
+}
+
 }   // end of anonymous namespace