From: Thomas Markwalder Date: Thu, 26 Jul 2018 20:11:58 +0000 (-0400) Subject: [5682] Added test that demonstrates broken lease update X-Git-Tag: ha_phase2~13 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=6f5ac609b7bc3ec948a56f18a4e0a1b5e4157b34;p=thirdparty%2Fkea.git [5682] Added test that demonstrates broken lease update --- diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc index 5192aa4383..9181209212 100644 --- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc +++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc @@ -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