|
@@ -1047,7 +1047,7 @@ TEST_F(LeaseCmdsTest, Lease4GetByAddr) {
|
|
ASSERT_TRUE(lease);
|
|
ASSERT_TRUE(lease);
|
|
|
|
|
|
// Let's check if the response makes any sense.
|
|
// Let's check if the response makes any sense.
|
|
- checkLease4(lease, "192.0.2.1", 44, "08:08:08:08:08:08", false);
|
|
|
|
|
|
+ checkLease4(lease, "192.0.2.1", 44, "08:08:08:08:08:08", true);
|
|
}
|
|
}
|
|
|
|
|
|
// Checks that lease4-get can handle a situation when the query is
|
|
// Checks that lease4-get can handle a situation when the query is
|
|
@@ -1122,6 +1122,53 @@ TEST_F(LeaseCmdsTest, Lease6GetByAddr6NotFound) {
|
|
testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
|
|
testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Checks that lease4-get can handle a situation when the query is
|
|
|
|
+// well formed, but the lease is not there.
|
|
|
|
+TEST_F(LeaseCmdsTest, Lease4GetByClientIdNotFound) {
|
|
|
|
+
|
|
|
|
+ // Initialize lease manager (false = v4, false = don't add a lease)
|
|
|
|
+ initLeaseMgr(false, false);
|
|
|
|
+
|
|
|
|
+ // No such lease.
|
|
|
|
+ string cmd =
|
|
|
|
+ "{\n"
|
|
|
|
+ " \"command\": \"lease4-get\",\n"
|
|
|
|
+ " \"arguments\": {"
|
|
|
|
+ " \"identifier-type\": \"client-id\","
|
|
|
|
+ " \"identifier\": \"01:02:03:04\","
|
|
|
|
+ " \"subnet-id\": 44"
|
|
|
|
+ " }\n"
|
|
|
|
+ "}";
|
|
|
|
+ string exp_rsp = "Lease not found.";
|
|
|
|
+ ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Check that lease4-get can find a lease by client identifier.
|
|
|
|
+TEST_F(LeaseCmdsTest, Lease4GetByClientId) {
|
|
|
|
+ // Initialize lease manager (false = v4, true = add a lease)
|
|
|
|
+ initLeaseMgr(false, true);
|
|
|
|
+
|
|
|
|
+ string cmd =
|
|
|
|
+ "{\n"
|
|
|
|
+ " \"command\": \"lease4-get\",\n"
|
|
|
|
+ " \"arguments\": {"
|
|
|
|
+ " \"identifier-type\": \"client-id\","
|
|
|
|
+ " \"identifier\": \"42:42:42:42:42:42:42:42\","
|
|
|
|
+ " \"subnet-id\": 44"
|
|
|
|
+ " }\n"
|
|
|
|
+ "}";
|
|
|
|
+ string exp_rsp = "IPv4 lease found.";
|
|
|
|
+ ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
|
|
|
|
+
|
|
|
|
+ // Now check that the lease parameters were indeed returned.
|
|
|
|
+ ASSERT_TRUE(rsp);
|
|
|
|
+ ConstElementPtr lease = rsp->get("arguments");
|
|
|
|
+ ASSERT_TRUE(lease);
|
|
|
|
+
|
|
|
|
+ // Let's check if the response makes any sense.
|
|
|
|
+ checkLease4(lease, "192.0.2.1", 44, "08:08:08:08:08:08", false);
|
|
|
|
+}
|
|
|
|
+
|
|
// Checks that lease6-get(subnet-id, addr) can handle a situation when
|
|
// Checks that lease6-get(subnet-id, addr) can handle a situation when
|
|
// the query is correctly formed, but the lease is not there.
|
|
// the query is correctly formed, but the lease is not there.
|
|
TEST_F(LeaseCmdsTest, Lease6GetByDuidNotFound) {
|
|
TEST_F(LeaseCmdsTest, Lease6GetByDuidNotFound) {
|
|
@@ -1794,6 +1841,52 @@ TEST_F(LeaseCmdsTest, Lease4DelByHWAddr) {
|
|
EXPECT_FALSE(lmptr_->getLease4(IOAddress("192.0.2.1")));
|
|
EXPECT_FALSE(lmptr_->getLease4(IOAddress("192.0.2.1")));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Checks that lease4-del can handle a situation when the query is
|
|
|
|
+// well formed, but the lease is not there.
|
|
|
|
+TEST_F(LeaseCmdsTest, Lease4DelByClientIdNotFound) {
|
|
|
|
+
|
|
|
|
+ // Initialize lease manager (false = v4, true = add a lease)
|
|
|
|
+ initLeaseMgr(false, true);
|
|
|
|
+
|
|
|
|
+ // No such lease.
|
|
|
|
+ string cmd =
|
|
|
|
+ "{\n"
|
|
|
|
+ " \"command\": \"lease4-del\",\n"
|
|
|
|
+ " \"arguments\": {"
|
|
|
|
+ " \"identifier-type\": \"client-id\","
|
|
|
|
+ " \"identifier\": \"01:02:03:04\","
|
|
|
|
+ " \"subnet-id\": 44"
|
|
|
|
+ " }\n"
|
|
|
|
+ "}";
|
|
|
|
+ string exp_rsp = "IPv4 lease not found.";
|
|
|
|
+ ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
|
|
|
|
+
|
|
|
|
+ // Make sure the lease is still there.
|
|
|
|
+ EXPECT_TRUE(lmptr_->getLease4(IOAddress("192.0.2.1")));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Checks that lease4-del can find and delete a lease by client identifier.
|
|
|
|
+TEST_F(LeaseCmdsTest, Lease4DelByClientId) {
|
|
|
|
+ // Initialize lease manager (false = v4, true = add a lease)
|
|
|
|
+ initLeaseMgr(false, true);
|
|
|
|
+
|
|
|
|
+ // Invalid
|
|
|
|
+ string cmd =
|
|
|
|
+ "{\n"
|
|
|
|
+ " \"command\": \"lease4-del\",\n"
|
|
|
|
+ " \"arguments\": {"
|
|
|
|
+ " \"identifier-type\": \"client-id\","
|
|
|
|
+ " \"identifier\": \"42:42:42:42:42:42:42:42\","
|
|
|
|
+ " \"subnet-id\": 44"
|
|
|
|
+ " }\n"
|
|
|
|
+ "}";
|
|
|
|
+ string exp_rsp = "IPv4 lease deleted.";
|
|
|
|
+ ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
|
|
|
|
+
|
|
|
|
+ // Make sure the lease is really gone.
|
|
|
|
+ EXPECT_FALSE(lmptr_->getLease4(IOAddress("192.0.2.1")));
|
|
|
|
+}
|
|
|
|
+
|
|
// Checks that lease6-del(addr) can handle a situation when
|
|
// Checks that lease6-del(addr) can handle a situation when
|
|
// the query is correctly formed, but the lease is not there.
|
|
// the query is correctly formed, but the lease is not there.
|
|
TEST_F(LeaseCmdsTest, Lease6DelByAddr6NotFound) {
|
|
TEST_F(LeaseCmdsTest, Lease6DelByAddr6NotFound) {
|