Commit 7c492a54 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[5468] Added test for empty lease set for lease4-get-all.

parent 369ff550
......@@ -1156,10 +1156,39 @@ TEST_F(LeaseCmdsTest, Lease4GetAll) {
checkLease4(leases, "192.0.3.2", 88, "09:09:09:09:09:09", true);
}
// Checks that lease4-get-all returns empty set if no leases are found.
TEST_F(LeaseCmdsTest, Lease4GetAllNoLeases) {
// Initialize lease manager (false = v4, false = do not add leasesxs)
initLeaseMgr(false, false);
// Query for all leases.
string cmd =
"{\n"
" \"command\": \"lease4-get-all\"\n"
"}";
string exp_rsp = "0 IPv4 lease(s) found.";
ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
// Now check that the lease parameters were indeed returned.
ASSERT_TRUE(rsp);
ConstElementPtr args = rsp->get("arguments");
ASSERT_TRUE(args);
ASSERT_EQ(Element::map, args->getType());
ConstElementPtr leases = args->get("leases");
ASSERT_TRUE(leases);
ASSERT_EQ(Element::list, leases->getType());
EXPECT_EQ(0, leases->size());
}
// Checks that lease4-get-all returns all leases for a subnet.
TEST_F(LeaseCmdsTest, Lease4GetAllBySubnetId) {
// Initialize lease manager (false = v4, true = add a lease)
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
// Query for leases from subnet 44. Subnet 127 will be ignored because
......@@ -1190,6 +1219,38 @@ TEST_F(LeaseCmdsTest, Lease4GetAllBySubnetId) {
checkLease4(leases, "192.0.2.2", 44, "09:09:09:09:09:09", true);
}
// Checks that lease4-get-all returns empty set when no leases are found.
TEST_F(LeaseCmdsTest, Lease4GetAllBySubnetIdNoLeases) {
// Initialize lease manager (false = v4, true = do not add leases)
initLeaseMgr(false, false);
// Query for leases from subnet 44. Subnet 127 will be ignored because
// it doesn't contain any leases.
string cmd =
"{\n"
" \"command\": \"lease4-get-all\",\n"
" \"arguments\": {\n"
" \"subnets\": [ 44, 127 ]"
" }\n"
"}";
string exp_rsp = "0 IPv4 lease(s) found.";
ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
// Now check that the lease parameters were indeed returned.
ASSERT_TRUE(rsp);
ConstElementPtr args = rsp->get("arguments");
ASSERT_TRUE(args);
ASSERT_EQ(Element::map, args->getType());
ConstElementPtr leases = args->get("leases");
ASSERT_TRUE(leases);
ASSERT_EQ(Element::list, leases->getType());
EXPECT_EQ(0, leases->size());
}
// Checks that lease4-get-all returns leases from multiple subnets.
TEST_F(LeaseCmdsTest, Lease4GetAllByMultipleSubnetIds) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment