]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5682] Added test that demonstrates broken lease update
authorThomas Markwalder <tmark@isc.org>
Thu, 26 Jul 2018 20:11:58 +0000 (16:11 -0400)
committerTomek Mrugalski <tomasz@isc.org>
Mon, 30 Jul 2018 17:05:18 +0000 (19:05 +0200)
src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc

index 5192aa4383f89cbb1353e3bca6c0cbc1f9ebc5fb..91812092127c5a3dea7a9d963f6042fe51faafdb 100644 (file)
@@ -3729,4 +3729,33 @@ TEST_F(LeaseCmdsTest, Lease6WipeNoLeasesAll) {
     testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
 }
 
+TEST_F(LeaseCmdsTest, brokenUpdate) {
+
+    // Initialize lease manager (false = v4, false = don't add leases)
+    initLeaseMgr(false, false);
+
+    // Set the sanity checks level.
+    CfgMgr::instance().getCurrentCfg()->getConsistency()
+        ->setLeaseSanityCheck(CfgConsistency::LEASE_CHECK_FIX);
+
+    // Check that the lease manager pointer is there.
+    ASSERT_TRUE(lmptr_);
+
+    // Now send the command.
+    string txt =
+        "{\n"
+        "    \"command\": \"lease4-update\",\n"
+        "    \"arguments\": {"
+        "        \"subnet-id\": 444,\n"
+        "        \"ip-address\": \"192.0.2.202\",\n"
+        "        \"hw-address\": \"1a:1b:1c:1d:1e:1f\"\n"
+        "        ,\"force-create\": true\n"
+        "    }\n"
+        "}";
+    string exp_rsp = "Invalid subnet-id: No IPv4 subnet with "
+                     "subnet-id=444 currently configured.";
+    testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
+}
+
+
 } // end of anonymous namespace