summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRazvan Becheriu <razvan@isc.org>2023-06-19 16:28:13 +0200
committerRazvan Becheriu <razvan@isc.org>2023-06-22 16:52:48 +0200
commit21ff30b1121b7726d7919f4cbb29a9120ba5c5fe (patch)
tree8babf4d64f087a2597028b55ca4f768f606ed6de
parent[#2898] add pool-id to yang models (diff)
downloadkea-21ff30b1121b7726d7919f4cbb29a9120ba5c5fe.tar.xz
kea-21ff30b1121b7726d7919f4cbb29a9120ba5c5fe.zip
[#2898] added unittests for pool-id
-rw-r--r--src/hooks/dhcp/lease_cmds/lease_parser.cc5
-rw-r--r--src/hooks/dhcp/lease_cmds/tests/lease_cmds4_unittest.cc236
-rw-r--r--src/hooks/dhcp/lease_cmds/tests/lease_cmds6_unittest.cc708
-rw-r--r--src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.h12
-rw-r--r--src/lib/dhcpsrv/alloc_engine.cc8
-rw-r--r--src/lib/dhcpsrv/lease.cc10
-rw-r--r--src/lib/dhcpsrv/lease_mgr.h2
-rw-r--r--src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc3
-rw-r--r--src/lib/dhcpsrv/tests/lease_unittest.cc28
-rw-r--r--src/lib/dhcpsrv/testutils/test_utils.cc2
10 files changed, 646 insertions, 368 deletions
diff --git a/src/hooks/dhcp/lease_cmds/lease_parser.cc b/src/hooks/dhcp/lease_cmds/lease_parser.cc
index 2871c1cd94..32ac214ff6 100644
--- a/src/hooks/dhcp/lease_cmds/lease_parser.cc
+++ b/src/hooks/dhcp/lease_cmds/lease_parser.cc
@@ -55,6 +55,7 @@ Lease4Parser::parse(ConstSrvConfigPtr& cfg,
pool_id = getUint32(lease_info, "pool-id");
}
+ // Check if the subnet-id specified is sane.
ConstSubnet4Ptr subnet;
if (subnet_id) {
// If subnet-id is specified, it has to match.
@@ -64,6 +65,7 @@ Lease4Parser::parse(ConstSrvConfigPtr& cfg,
<< subnet_id << " currently configured.");
}
+ // Check if the address specified really belongs to the subnet.
if (!subnet->inRange(addr)) {
isc_throw(LeaseCmdsConflict, "The address " << addr.toText() << " does not belong "
"to subnet " << subnet->toText() << ", subnet-id=" << subnet_id);
@@ -170,7 +172,6 @@ Lease4Parser::parse(ConstSrvConfigPtr& cfg,
}
// Let's fabricate some data and we're ready to go.
-
Lease4Ptr l(new Lease4(addr, hwaddr_ptr, client_id, valid_lft,
cltt, subnet_id,
fqdn_fwd, fqdn_rev, hostname));
@@ -265,6 +266,7 @@ Lease6Parser::parse(ConstSrvConfigPtr& cfg,
isc_throw(BadValue, "Subnet-id is 0 or not specified. This is allowed for"
" address leases only, not prefix leases.");
}
+ // Subnet-id was not specified. Let's try to figure it out on our own.
subnet = cfg->getCfgSubnets6()->selectSubnet(addr);
if (!subnet) {
isc_throw(LeaseCmdsConflict, "subnet-id not specified and failed to find a "
@@ -382,7 +384,6 @@ Lease6Parser::parse(ConstSrvConfigPtr& cfg,
}
// Let's fabricate some data and we're ready to go.
-
Lease6Ptr l(new Lease6(type, addr, duid_ptr, iaid, pref_lft, valid_lft,
subnet_id, fqdn_fwd, fqdn_rev, hostname,
hwaddr_ptr, prefix_len));
diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds4_unittest.cc b/src/hooks/dhcp/lease_cmds/tests/lease_cmds4_unittest.cc
index fef1132152..34f5e02952 100644
--- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds4_unittest.cc
+++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds4_unittest.cc
@@ -59,7 +59,7 @@ public:
/// @param client_id_required true if client-id is expected
void checkLease4(isc::data::ConstElementPtr l, std::string ip,
uint32_t subnet_id, std::string hwaddr,
- bool client_id_required) {
+ bool client_id_required, uint32_t pool_id = 0) {
ASSERT_TRUE(l);
// If the element is a list we need to retrieve the lease that
@@ -91,7 +91,14 @@ public:
EXPECT_TRUE(l->get("client-id"));
}
- // Check that other parameters are there.
+ if (pool_id) {
+ ASSERT_TRUE(l->get("pool-id"));
+ EXPECT_EQ(pool_id, l->get("pool-id")->intValue());
+ } else {
+ EXPECT_FALSE(l->get("pool-id"));
+ }
+
+ // Check that all expected fields are there.
ASSERT_TRUE(l->contains("valid-lft"));
ASSERT_TRUE(l->contains("cltt"));
ASSERT_TRUE(l->contains("subnet-id"));
@@ -101,7 +108,7 @@ public:
ASSERT_TRUE(l->contains("hostname"));
ASSERT_TRUE(l->contains("state"));
- // Check that there are no v6 specific fields
+ // Check that there are no v6 specific fields.
ASSERT_FALSE(l->contains("prefix"));
ASSERT_FALSE(l->contains("duid"));
ASSERT_FALSE(l->contains("preferred-lft"));
@@ -243,6 +250,9 @@ public:
/// @brief Verifies that the limit must be a number.
void testLease4GetPagedLimitNotNumber();
+ /// @brief Verifies that the limit of 0 is rejected.
+ void testLease4GetPagedLimitIsZero();
+
/// @brief Check that lease4-get-by-hw-address can handle a situation when
/// the query is broken (required parameter is missing).
void testLease4GetByHwAddressParams();
@@ -267,9 +277,6 @@ public:
/// leases).
void testLease4GetByClientIdFind2();
- /// @brief Verifies that the limit of 0 is rejected.
- void testLease4GetPagedLimitIsZero();
-
/// @brief Check that lease4-get-by-hostname can handle a situation when
/// the query is broken (required parameter is missing).
void testLease4GetByHostnameParams();
@@ -439,7 +446,7 @@ void Lease4CmdsTest::testLease4AddMissingParams() {
// Initialize lease manager (false = v4, false = don't add leases)
initLeaseMgr(false, false);
- // Everything missing. What sort of crap is that?
+ // Everything missing. What sort of nonsense is that?
string txt =
"{\n"
" \"command\": \"lease4-add\",\n"
@@ -461,7 +468,7 @@ void Lease4CmdsTest::testLease4AddMissingParams() {
exp_rsp = "missing parameter 'hw-address' (<string>:3:19)";
testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
- // Better, but still no luck. (hwaddr missing).
+ // Just subnet-id and ip is not enough. (hwaddr missing).
txt =
"{\n"
" \"command\": \"lease4-add\",\n"
@@ -530,7 +537,7 @@ void Lease4CmdsTest::testLease4AddBadParams() {
exp_rsp = "Non-IPv4 address specified: 2001:db8:1::1";
testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
- // currently defined states are 0,1 and 2. 123 is junk.
+ // Invalid state: the only supported values are 0,1,2.
txt =
"{\n"
" \"command\": \"lease4-add\",\n"
@@ -574,6 +581,38 @@ void Lease4CmdsTest::testLease4AddBadParams() {
exp_rsp = "Duplicated comment entry '\"direct\"' in user context "
"'{ \"comment\": \"in user context\" }'";
testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
+
+ // Negative expiration time.
+ txt =
+ "{\n"
+ " \"command\": \"lease4-add\",\n"
+ " \"arguments\": {"
+ " \"subnet-id\": 44,\n"
+ " \"ip-address\": \"192.0.2.1\",\n"
+ " \"hw-address\": \"1a:1b:1c:1d:1e:1f\",\n"
+ " \"user-context\": { \"comment\": \"in user context\" },\n"
+ " \"expire\": -6218189367\n"
+ " }\n"
+ "}";
+ exp_rsp = "expiration time must be positive for address 192.0.2.1";
+ testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
+
+ // Negative cltt
+ txt =
+ "{\n"
+ " \"command\": \"lease4-add\",\n"
+ " \"arguments\": {"
+ " \"subnet-id\": 44,\n"
+ " \"ip-address\": \"192.0.2.1\",\n"
+ " \"hw-address\": \"1a:1b:1c:1d:1e:1f\",\n"
+ " \"user-context\": { \"comment\": \"in user context\" },\n"
+ " \"expire\": 123456,\n"
+ " \"valid-lft\": 123457"
+ " }\n"
+ "}";
+ exp_rsp = "expiration time must be greater than valid lifetime for address "
+ "192.0.2.1";
+ testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
}
void Lease4CmdsTest::testLease4Add() {
@@ -651,7 +690,7 @@ void Lease4CmdsTest::testLease4AddDeclinedLeases() {
Lease4Ptr l = lmptr_->getLease4(IOAddress("192.0.2.202"));
ASSERT_TRUE(l);
- // Make sure the lease have proper value set.
+ // Make sure the lease has proper value set.
ASSERT_TRUE(l->hwaddr_);
EXPECT_EQ("1a:1b:1c:1d:1e:1f", l->hwaddr_->toText(false));
EXPECT_EQ(3, l->valid_lft_); // taken from subnet configuration
@@ -718,7 +757,7 @@ void Lease4CmdsTest::testLease4AddSubnetIdMissing() {
checkLease4Stats(88, 0, 0);
- // Now check that the lease is really there.
+ // Now check that the lease is really there and has correct subnet-id.
Lease4Ptr l = lmptr_->getLease4(IOAddress("192.0.2.202"));
ASSERT_TRUE(l);
EXPECT_EQ(44, l->subnet_id_);
@@ -750,7 +789,7 @@ void Lease4CmdsTest::testLease4AddSubnetIdMissingDeclinedLeases() {
checkLease4Stats(88, 0, 0);
- // Now check that the lease is really there.
+ // Now check that the lease is really there and has correct subnet-id.
Lease4Ptr l = lmptr_->getLease4(IOAddress("192.0.2.202"));
ASSERT_TRUE(l);
EXPECT_EQ(44, l->subnet_id_);
@@ -871,6 +910,7 @@ void Lease4CmdsTest::testLease4AddFullAddr() {
" \"fqdn-fwd\": true,\n"
" \"fqdn-rev\": true,\n"
" \"hostname\": \"urania.example.org\",\n"
+ " \"pool-id\": 5,\n"
" \"user-context\": { \"foobar\": true }\n"
" }\n"
"}";
@@ -894,6 +934,7 @@ void Lease4CmdsTest::testLease4AddFullAddr() {
EXPECT_EQ(true, l->fqdn_fwd_);
EXPECT_EQ(true, l->fqdn_rev_);
EXPECT_EQ("urania.example.org", l->hostname_);
+ EXPECT_EQ(5, l->pool_id_);
ASSERT_TRUE(l->getContext());
EXPECT_EQ("{ \"foobar\": true }", l->getContext()->str());
}
@@ -928,7 +969,7 @@ void Lease4CmdsTest::testLease4AddComment() {
Lease4Ptr l = lmptr_->getLease4(IOAddress("192.0.2.202"));
ASSERT_TRUE(l);
- // Make sure the lease have proper value set.
+ // Make sure the lease has proper value set.
ASSERT_TRUE(l->hwaddr_);
EXPECT_EQ("1a:1b:1c:1d:1e:1f", l->hwaddr_->toText(false));
ASSERT_TRUE(l->getContext());
@@ -981,9 +1022,11 @@ void Lease4CmdsTest::testLease4AddExtendedInfo() {
Lease4Ptr l = lmptr_->getLease4(IOAddress("192.0.2.202"));
ASSERT_TRUE(l);
- // Make sure the lease have proper value set.
+ // Make sure the lease has proper value set.
ASSERT_TRUE(l->hwaddr_);
EXPECT_EQ("1a:1b:1c:1d:1e:1f", l->hwaddr_->toText(false));
+
+ // Check the user context / extended info too.
ConstElementPtr ctx = l->getContext();
ASSERT_TRUE(ctx);
string expected = "{ \"ISC\": { \"relay-agent-info\": ";
@@ -1122,14 +1165,17 @@ void Lease4CmdsTest::testLease4GetByAddrNotFound() {
" }\n"
"}";
string exp_rsp = "Lease not found.";
- ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
+
+ // Note the status expected is empty. The query completed correctly,
+ // just didn't found the lease.
+ testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
}
void Lease4CmdsTest::testLease4GetByAddr() {
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
- // Query for valid, existing lease.
+ // Now send the command.
string cmd =
"{\n"
" \"command\": \"lease4-get\",\n"
@@ -1138,14 +1184,17 @@ void Lease4CmdsTest::testLease4GetByAddr() {
" }\n"
"}";
string exp_rsp = "IPv4 lease found.";
+
+ // The status expected is success. The lease should be returned.
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.
+ // Now check that the lease was indeed returned.
checkLease4(lease, "192.0.2.1", 44, "08:08:08:08:08:08", true);
}
@@ -1164,14 +1213,14 @@ void Lease4CmdsTest::testLease4GetByHWAddrNotFound() {
" }\n"
"}";
string exp_rsp = "Lease not found.";
- ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
+ testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
}
void Lease4CmdsTest::testLease4GetByHWAddr() {
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
- // Invalid
+ // Now send the command.
string cmd =
"{\n"
" \"command\": \"lease4-get\",\n"
@@ -1182,14 +1231,17 @@ void Lease4CmdsTest::testLease4GetByHWAddr() {
" }\n"
"}";
string exp_rsp = "IPv4 lease found.";
+
+ // The status expected is success. The lease should be returned.
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.
+ // Now check that the lease was indeed returned.
checkLease4(lease, "192.0.2.1", 44, "08:08:08:08:08:08", false);
}
@@ -1208,7 +1260,7 @@ void Lease4CmdsTest::testLease4GetByClientIdNotFound() {
" }\n"
"}";
string exp_rsp = "Lease not found.";
- ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
+ testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
}
void Lease4CmdsTest::testLease4GetByClientId() {
@@ -1225,14 +1277,17 @@ void Lease4CmdsTest::testLease4GetByClientId() {
" }\n"
"}";
string exp_rsp = "IPv4 lease found.";
+
+ // The status expected is success. The lease should be returned.
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.
+ // Now check that the lease was indeed returned.
checkLease4(lease, "192.0.2.1", 44, "08:08:08:08:08:08", false);
}
@@ -1261,7 +1316,7 @@ void Lease4CmdsTest::testLease4GetAll() {
// Let's check if the response contains desired leases.
checkLease4(leases, "192.0.2.1", 44, "08:08:08:08:08:08", true);
- checkLease4(leases, "192.0.2.2", 44, "09:09:09:09:09:09", true);
+ checkLease4(leases, "192.0.2.2", 44, "09:09:09:09:09:09", true, 5);
checkLease4(leases, "192.0.3.1", 88, "08:08:08:08:08:08", true);
checkLease4(leases, "192.0.3.2", 88, "09:09:09:09:09:09", true);
}
@@ -1321,7 +1376,7 @@ void Lease4CmdsTest::testLease4GetAllBySubnetId() {
// Let's check if the response contains desired leases.
checkLease4(leases, "192.0.2.1", 44, "08:08:08:08:08:08", true);
- checkLease4(leases, "192.0.2.2", 44, "09:09:09:09:09:09", true);
+ checkLease4(leases, "192.0.2.2", 44, "09:09:09:09:09:09", true, 5);
}
void Lease4CmdsTest::testLease4GetAllBySubnetIdNoLeases() {
@@ -1382,7 +1437,7 @@ void Lease4CmdsTest::testLease4GetAllByMultipleSubnetIds() {
// Let's check if the response contains desired leases.
checkLease4(leases, "192.0.2.1", 44, "08:08:08:08:08:08", true);
- checkLease4(leases, "192.0.2.2", 44, "09:09:09:09:09:09", true);
+ checkLease4(leases, "192.0.2.2", 44, "09:09:09:09:09:09", true, 5);
checkLease4(leases, "192.0.3.1", 88, "08:08:08:08:08:08", true);
checkLease4(leases, "192.0.3.2", 88, "09:09:09:09:09:09", true);
}
@@ -1498,8 +1553,12 @@ void Lease4CmdsTest::testLease4GetPaged() {
// ask the Lease Manager.
Lease4Ptr from_mgr = LeaseMgrFactory::instance().getLease4(IOAddress(last_address));
ASSERT_TRUE(from_mgr);
+ uint32_t pool_id = 0;
+ if (last_address == "192.0.2.2") {
+ pool_id = 5;
+ }
checkLease4(leases, last_address, from_mgr->subnet_id_,
- from_mgr->hwaddr_->toText(false), true);
+ from_mgr->hwaddr_->toText(false), true, pool_id);
}
} else {
@@ -1881,7 +1940,7 @@ void Lease4CmdsTest::testLease4UpdateMissingParams() {
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
- // Everything missing. What sort of crap is that?
+ // Everything missing. What sort of nonsense is that?
string txt =
"{\n"
" \"command\": \"lease4-update\",\n"
@@ -1892,7 +1951,7 @@ void Lease4CmdsTest::testLease4UpdateMissingParams() {
testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
// Just ip is not enough (subnet-id and hwaddr missing, although
- // Kea can now figure out subnet-id on its own).
+ // Kea should be able to figure out the subnet-id on its own).
txt =
"{\n"
" \"command\": \"lease4-update\",\n"
@@ -2007,6 +2066,10 @@ void Lease4CmdsTest::testLease4UpdateNoLease() {
// Initialize lease manager (false = v4, false = don't add leases)
initLeaseMgr(false, false);
+ checkLease4Stats(44, 0, 0);
+
+ checkLease4Stats(88, 0, 0);
+
// Now send the command.
string txt =
"{\n"
@@ -2022,6 +2085,10 @@ void Lease4CmdsTest::testLease4UpdateNoLease() {
"either because the lease has been deleted or it has changed in the "
"database, in both cases a retry might succeed";
testCommand(txt, CONTROL_RESULT_CONFLICT, exp_rsp);
+
+ checkLease4Stats(44, 0, 0);
+
+ checkLease4Stats(88, 0, 0);
}
void Lease4CmdsTest::testLease4Update() {
@@ -2040,6 +2107,7 @@ void Lease4CmdsTest::testLease4Update() {
" \"subnet-id\": 44,\n"
" \"ip-address\": \"192.0.2.1\",\n"
" \"hw-address\": \"1a:1b:1c:1d:1e:1f\",\n"
+ " \"pool-id\": 3,\n"
" \"hostname\": \"newhostname.example.org\""
" }\n"
"}";
@@ -2050,13 +2118,14 @@ void Lease4CmdsTest::testLease4Update() {
checkLease4Stats(88, 2, 0);
- // Now check that the lease is still there.
+ // Now check that the lease is really there.
Lease4Ptr l = lmptr_->getLease4(IOAddress("192.0.2.1"));
ASSERT_TRUE(l);
- // Make sure it's been updated.
+ // Make sure the lease has been updated.
ASSERT_TRUE(l->hwaddr_);
EXPECT_EQ("1a:1b:1c:1d:1e:1f", l->hwaddr_->toText(false));
+ EXPECT_EQ(3, l->pool_id_);
EXPECT_EQ("newhostname.example.org", l->hostname_);
EXPECT_FALSE(l->getContext());
}
@@ -2077,6 +2146,7 @@ void Lease4CmdsTest::testLease4UpdateDeclinedLeases() {
" \"subnet-id\": 44,\n"
" \"ip-address\": \"192.0.2.1\",\n"
" \"hw-address\": \"1a:1b:1c:1d:1e:1f\",\n"
+ " \"pool-id\": 3,\n"
" \"hostname\": \"newhostname.example.org\""
" }\n"
"}";
@@ -2091,9 +2161,10 @@ void Lease4CmdsTest::testLease4UpdateDeclinedLeases() {
Lease4Ptr l = lmptr_->getLease4(IOAddress("192.0.2.1"));
ASSERT_TRUE(l);
- // Make sure it's been updated.
+ // Make sure the lease has been updated.
ASSERT_TRUE(l->hwaddr_);
EXPECT_EQ("1a:1b:1c:1d:1e:1f", l->hwaddr_->toText(false));
+ EXPECT_EQ(3, l->pool_id_);
EXPECT_EQ("newhostname.example.org", l->hostname_);
EXPECT_FALSE(l->getContext());
}
@@ -2127,7 +2198,10 @@ void Lease4CmdsTest::testLease4UpdateNoSubnetId() {
Lease4Ptr l = lmptr_->getLease4(IOAddress("192.0.2.1"));
ASSERT_TRUE(l);
- // Make sure it's been updated.
+ // Make sure the subnet-id is correct.
+ EXPECT_EQ(44, l->subnet_id_);
+
+ // Make sure the lease has been updated.
ASSERT_TRUE(l->hwaddr_);
EXPECT_EQ("1a:1b:1c:1d:1e:1f", l->hwaddr_->toText(false));
EXPECT_EQ("newhostname.example.org", l->hostname_);
@@ -2159,11 +2233,14 @@ void Lease4CmdsTest::testLease4UpdateNoSubnetIdDeclinedLeases() {
checkLease4Stats(88, 2, 2);
- // Now check that the lease is still there.
+ // Now check that the lease is really there.
Lease4Ptr l = lmptr_->getLease4(IOAddress("192.0.2.1"));
ASSERT_TRUE(l);
- // Make sure it's been updated.
+ // Make sure the subnet-id is correct.
+ EXPECT_EQ(44, l->subnet_id_);
+
+ // Make sure the lease has been updated.
ASSERT_TRUE(l->hwaddr_);
EXPECT_EQ("1a:1b:1c:1d:1e:1f", l->hwaddr_->toText(false));
EXPECT_EQ("newhostname.example.org", l->hostname_);
@@ -2197,11 +2274,11 @@ void Lease4CmdsTest::testLease4UpdateForceCreate() {
checkLease4Stats(88, 0, 0);
- // Now check that the lease is still there.
+ // Now check that the lease is really there.
Lease4Ptr l = lmptr_->getLease4(IOAddress("192.0.2.1"));
ASSERT_TRUE(l);
- // Make sure it contains expected values..
+ // Make sure the lease is correct.
ASSERT_TRUE(l->hwaddr_);
EXPECT_EQ("1a:1b:1c:1d:1e:1f", l->hwaddr_->toText(false));
EXPECT_EQ("newhostname.example.org", l->hostname_);
@@ -2234,14 +2311,14 @@ void Lease4CmdsTest::testLease4UpdateForceCreateNoSubnetId() {
checkLease4Stats(88, 0, 0);
- // Now check that the lease is still there.
+ // Now check that the lease is really there.
Lease4Ptr l = lmptr_->getLease4(IOAddress("192.0.2.1"));
ASSERT_TRUE(l);
// Make sure the subnet-id is figured out correctly.
EXPECT_EQ(44, l->subnet_id_);
- // Make sure it contains expected values..
+ // Make sure the lease is correct.
ASSERT_TRUE(l->hwaddr_);
EXPECT_EQ("1a:1b:1c:1d:1e:1f", l->hwaddr_->toText(false));
EXPECT_EQ("newhostname.example.org", l->hostname_);
@@ -2305,11 +2382,11 @@ void Lease4CmdsTest::testLease4UpdateComment() {
checkLease4Stats(88, 2, 0);
- // Now check that the lease is still there.
+ // Now check that the lease is really there.
Lease4Ptr l = lmptr_->getLease4(IOAddress("192.0.2.1"));
ASSERT_TRUE(l);
- // Make sure it's been updated.
+ // Make sure the lease has been updated.
ASSERT_TRUE(l->hwaddr_);
EXPECT_EQ("42:42:42:42:42:42:42:42", l->hwaddr_->toText(false));
@@ -2365,15 +2442,15 @@ void Lease4CmdsTest::testLease4UpdateExtendedInfo() {
checkLease4Stats(88, 2, 0);
- // Now check that the lease is still there.
+ // Now check that the lease is really there.
Lease4Ptr l = lmptr_->getLease4(IOAddress("192.0.2.1"));
ASSERT_TRUE(l);
- // Make sure it's been updated.
+ // Make sure the lease has been updated.
ASSERT_TRUE(l->hwaddr_);
EXPECT_EQ("42:42:42:42:42:42:42:42", l->hwaddr_->toText(false));
- // Check user context.
+ // Check the user context / extended info too.
ConstElementPtr ctx = l->getContext();
ASSERT_TRUE(ctx);
string expected = "{ \"ISC\": { \"relay-agent-info\": ";
@@ -2479,7 +2556,7 @@ void Lease4CmdsTest::testLease4DelByAddrNotFound() {
checkLease4Stats(88, 2, 0);
- // Invalid
+ // Now send the command.
string cmd =
"{\n"
" \"command\": \"lease4-del\",\n"
@@ -2489,6 +2566,9 @@ void Lease4CmdsTest::testLease4DelByAddrNotFound() {
" }\n"
"}";
string exp_rsp = "IPv4 lease not found.";
+
+ // Note the status expected is empty. The query completed correctly,
+ // just didn't found the lease.
ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
checkLease4Stats(44, 2, 0);
@@ -2504,7 +2584,7 @@ void Lease4CmdsTest::testLease4DelByAddr() {
checkLease4Stats(88, 2, 0);
- // Query for valid, existing lease.
+ // Now send the command.
string cmd =
"{\n"
" \"command\": \"lease4-del\",\n"
@@ -2513,6 +2593,8 @@ void Lease4CmdsTest::testLease4DelByAddr() {
" }\n"
"}";
string exp_rsp = "IPv4 lease deleted.";
+
+ // The status expected is success. The lease should be deleted.
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
checkLease4Stats(44, 1, 0);
@@ -2531,7 +2613,7 @@ void Lease4CmdsTest::testLease4DelByAddrDeclinedLeases() {
checkLease4Stats(88, 2, 2);
- // Query for valid, existing lease.
+ // Now send the command.
string cmd =
"{\n"
" \"command\": \"lease4-del\",\n"
@@ -2540,6 +2622,8 @@ void Lease4CmdsTest::testLease4DelByAddrDeclinedLeases() {
" }\n"
"}";
string exp_rsp = "IPv4 lease deleted.";
+
+ // The status expected is success. The lease should be deleted.
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
checkLease4Stats(44, 1, 1);
@@ -2622,7 +2706,7 @@ void Lease4CmdsTest::testLease4DelByHWAddr() {
checkLease4Stats(88, 2, 0);
- // Invalid
+ // Now send the command.
string cmd =
"{\n"
" \"command\": \"lease4-del\",\n"
@@ -2633,6 +2717,8 @@ void Lease4CmdsTest::testLease4DelByHWAddr() {
" }\n"
"}";
string exp_rsp = "IPv4 lease deleted.";
+
+ // The status expected is success. The lease should be deleted.
ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
checkLease4Stats(44, 1, 0);
@@ -2680,7 +2766,7 @@ void Lease4CmdsTest::testLease4DelByClientId() {
checkLease4Stats(88, 2, 0);
- // Invalid
+ // Now send the command.
string cmd =
"{\n"
" \"command\": \"lease4-del\",\n"
@@ -2691,6 +2777,8 @@ void Lease4CmdsTest::testLease4DelByClientId() {
" }\n"
"}";
string exp_rsp = "IPv4 lease deleted.";
+
+ // The status expected is success. The lease should be deleted.
ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
checkLease4Stats(44, 1, 0);
@@ -2709,7 +2797,7 @@ void Lease4CmdsTest::testLease4Wipe() {
checkLease4Stats(88, 2, 0);
- // Query for valid, existing lease.
+ // Now send the command.
string cmd =
"{\n"
" \"command\": \"lease4-wipe\",\n"
@@ -2718,6 +2806,8 @@ void Lease4CmdsTest::testLease4Wipe() {
" }\n"
"}";
string exp_rsp = "Deleted 2 IPv4 lease(s) from subnet(s) 44";
+
+ // The status expected is success. The lease should be deleted.
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
checkLease4Stats(44, 0, 0);
@@ -2741,7 +2831,7 @@ void Lease4CmdsTest::testLease4WipeAll() {
checkLease4Stats(88, 2, 0);
- // Query for valid, existing lease.
+ // Now send the command.
string cmd =
"{\n"
" \"command\": \"lease4-wipe\",\n"
@@ -2750,6 +2840,8 @@ void Lease4CmdsTest::testLease4WipeAll() {
" }\n"
"}";
string exp_rsp = "Deleted 4 IPv4 lease(s) from subnet(s) 44 88";
+
+ // The status expected is success. The lease should be deleted.
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
checkLease4Stats(44, 0, 0);
@@ -2773,12 +2865,14 @@ void Lease4CmdsTest::testLease4WipeAllNoArgs() {
checkLease4Stats(88, 2, 0);
- // Query for valid, existing lease.
+ // Now send the command.
string cmd =
"{\n"
" \"command\": \"lease4-wipe\"\n"
"}";
string exp_rsp = "Deleted 4 IPv4 lease(s) from subnet(s) 44 88";
+
+ // The status expected is success. The lease should be deleted.
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
checkLease4Stats(44, 0, 0);
@@ -2910,6 +3004,7 @@ void Lease4CmdsTest::testLease4ResendDdnsDisabled() {
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ // Disable DDNS updating.
disableD2();
// Query for valid, existing lease.
@@ -2940,7 +3035,7 @@ void Lease4CmdsTest::testLease4ResendDdnsNoLease() {
" }\n"
"}\n";
string exp_rsp = "No lease found for: 192.0.2.5";
- ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
+ testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
}
void Lease4CmdsTest::testLease4ResendNoHostname() {
@@ -3782,6 +3877,24 @@ TEST_F(Lease4CmdsTest, lease4UpdateNoSubnetIdDeclinedLeasesMultiThreading) {
testLease4UpdateNoSubnetIdDeclinedLeases();
}
+TEST_F(Lease4CmdsTest, lease4UpdateComment) {
+ testLease4UpdateComment();
+}
+
+TEST_F(Lease4CmdsTest, lease4UpdateCommentMultiThreading) {
+ MultiThreadingTest mt(true);
+ testLease4UpdateComment();
+}
+
+TEST_F(Lease4CmdsTest, lease4UpdateExtendedInfo) {
+ testLease4UpdateExtendedInfo();
+}
+
+TEST_F(Lease4CmdsTest, lease4UpdateExtendedInfoMultiThreading) {
+ MultiThreadingTest mt(true);
+ testLease4UpdateExtendedInfo();
+}
+
TEST_F(Lease4CmdsTest, lease4UpdateForceCreate) {
testLease4UpdateForceCreate();
}
@@ -3809,24 +3922,6 @@ TEST_F(Lease4CmdsTest, lease4UpdateDoNotForceCreateMultiThreading) {
testLease4UpdateDoNotForceCreate();
}
-TEST_F(Lease4CmdsTest, lease4UpdateComment) {
- testLease4UpdateComment();
-}
-
-TEST_F(Lease4CmdsTest, lease4UpdateCommentMultiThreading) {
- MultiThreadingTest mt(true);
- testLease4UpdateComment();
-}
-
-TEST_F(Lease4CmdsTest, lease4UpdateExtendedInfo) {
- testLease4UpdateExtendedInfo();
-}
-
-TEST_F(Lease4CmdsTest, lease4UpdateExtendedInfoMultiThreading) {
- MultiThreadingTest mt(true);
- testLease4UpdateExtendedInfo();
-}
-
TEST_F(Lease4CmdsTest, lease4DelMissingParams) {
testLease4DelMissingParams();
}
@@ -3953,7 +4048,6 @@ TEST_F(Lease4CmdsTest, lease4WipeNoLeasesAllMultiThreading) {
testLease4WipeNoLeasesAll();
}
-
TEST_F(Lease4CmdsTest, lease4BrokenUpdate) {
testLease4BrokenUpdate();
}
diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds6_unittest.cc b/src/hooks/dhcp/lease_cmds/tests/lease_cmds6_unittest.cc
index d1fc8ab99e..8ac316f416 100644
--- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds6_unittest.cc
+++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds6_unittest.cc
@@ -59,9 +59,8 @@ public:
/// @param duid expected value of DUID
/// @param hwaddr_required true if hwaddr is expected
void checkLease6(isc::data::ConstElementPtr l, std::string ip,
- uint8_t prefixlen,
- uint32_t subnet_id, std::string duid,
- bool hwaddr_required) {
+ uint8_t prefixlen, uint32_t subnet_id, std::string duid,
+ bool hwaddr_required, uint32_t pool_id = 0) {
ASSERT_TRUE(l);
// If the element is a list we need to retrieve the lease that
@@ -79,17 +78,17 @@ public:
ASSERT_TRUE(l);
}
- ASSERT_TRUE(l->contains("ip-address"));
+ ASSERT_TRUE(l->get("ip-address"));
EXPECT_EQ(ip, l->get("ip-address")->stringValue());
if (prefixlen != 0) {
ASSERT_TRUE(l->get("prefix-len"));
EXPECT_EQ(prefixlen, l->get("prefix-len")->intValue());
}
- ASSERT_TRUE(l->contains("subnet-id"));
+ ASSERT_TRUE(l->get("subnet-id"));
EXPECT_EQ(subnet_id, l->get("subnet-id")->intValue());
- ASSERT_TRUE(l->contains("duid"));
+ ASSERT_TRUE(l->get("duid"));
EXPECT_EQ(duid, l->get("duid")->stringValue());
// hwaddr may or may not appear
@@ -97,7 +96,14 @@ public:
EXPECT_TRUE(l->get("hwaddr"));
}
- // Check that there are expected fields
+ if (pool_id) {
+ ASSERT_TRUE(l->get("pool-id"));
+ EXPECT_EQ(pool_id, l->get("pool-id")->intValue());
+ } else {
+ EXPECT_FALSE(l->get("pool-id"));
+ }
+
+ // Check that all expected fields are there.
ASSERT_TRUE(l->contains("preferred-lft"));
ASSERT_TRUE(l->contains("valid-lft"));
ASSERT_TRUE(l->contains("cltt"));
@@ -184,6 +190,10 @@ public:
/// @brief Check that a well formed lease6 with a comment can be added.
void testLease6AddComment();
+ /// @brief Check that a well formed lease6 with relay and remote ids
+ /// can be added.
+ void testLease6AddExtendedInfo();
+
/// @brief Check that lease6-get can handle a situation when the query is
/// broken (some required parameters are missing).
void testLease6GetMissingParams();
@@ -201,14 +211,14 @@ public:
/// @brief Check that lease6-get can return a lease by prefix.
void testLease6GetByAddrPrefix();
- /// @bfief Check that lease6-get rejects queries by client-id.
+ /// @brief Check that lease6-get rejects queries by client-id.
void testLease6GetByClientIdInvalidType();
/// @brief Check that lease6-get can handle a situation when the query is
/// correctly formed, but the lease is not there.
void testLease6GetByDuidNotFound();
- /// @bfief Check that lease6-get can find a lease by duid.
+ /// @brief Check that lease6-get can find a lease by duid.
void testLease6GetByDuid();
/// @brief Check that lease6-get-all returns all leases.
@@ -289,10 +299,6 @@ public:
/// lease to be updated.
void testLease6UpdateNoLease();
- /// @brief Check that a lease6 can be updated. We're changing hw-address,
- /// hostname and extended info.
- void testLease6UpdateExtendedInfo();
-
/// @brief Check that a lease6 can be updated. We're changing hw-address and
/// a hostname.
void testLease6Update();
@@ -328,6 +334,10 @@ public:
/// user context.
void testLease6UpdateComment();
+ /// @brief Check that a lease6 can be updated. We're changing hw-address,
+ /// hostname and extended info.
+ void testLease6UpdateExtendedInfo();
+
/// @brief Check that lease6-del can handle a situation when the query is
/// broken (some required parameters are missing).
void testLease6DelMissingParams();
@@ -479,8 +489,8 @@ void Lease6CmdsTest::testLease6AddMissingParams() {
string exp_rsp = "missing parameter 'ip-address' (<string>:3:19)";
testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
- // Just ip is not enough (subnet-id and duid missing, but subnet-id
- // can now be figured out by kea)
+ // Just ip is not enough (subnet-id and duid missing, although
+ // subnet-id can now be figured out by Kea code)
txt =
"{\n"
" \"command\": \"lease6-add\",\n"
@@ -718,6 +728,13 @@ void Lease6CmdsTest::testLease6Add() {
// Now check that the lease is really there.
Lease6Ptr l = lmptr_->getLease6(Lease::TYPE_NA, IOAddress("2001:db8:1::3"));
ASSERT_TRUE(l);
+
+ // Make sure the lease has proper value set.
+ ASSERT_TRUE(l->duid_);
+ EXPECT_EQ("1a:1b:1c:1d:1e:1f", l->duid_->toText());
+ EXPECT_EQ(4, l->valid_lft_); // taken from subnet configuration
+ EXPECT_FALSE(l->fqdn_fwd_);
+ EXPECT_FALSE(l->fqdn_rev_);
EXPECT_EQ("", l->hostname_);
EXPECT_FALSE(l->getContext());
@@ -758,6 +775,13 @@ void Lease6CmdsTest::testLease6AddDeclinedLeases() {
// Now check that the lease is really there.
Lease6Ptr l = lmptr_->getLease6(Lease::TYPE_NA, IOAddress("2001:db8:1::3"));
ASSERT_TRUE(l);
+
+ // Make sure the lease has proper value set.
+ ASSERT_TRUE(l->duid_);
+ EXPECT_EQ("1a:1b:1c:1d:1e:1f", l->duid_->toText());
+ EXPECT_EQ(4, l->valid_lft_); // taken from subnet configuration
+ EXPECT_FALSE(l->fqdn_fwd_);
+ EXPECT_FALSE(l->fqdn_rev_);
EXPECT_EQ("", l->hostname_);
EXPECT_FALSE(l->getContext());
@@ -803,7 +827,8 @@ void Lease6CmdsTest::testLease6AddSubnetIdMissing() {
checkLease6Stats(99, 0, 0, 0);
- // Now send the command (without subnet-id)
+ // Now send the command without subnet-id. Kea should select
+ // the subnet id on its own.
string txt =
"{\n"
" \"command\": \"lease6-add\",\n"
@@ -834,7 +859,8 @@ void Lease6CmdsTest::testLease6AddSubnetIdMissingDeclinedLeases() {
checkLease6Stats(99, 0, 0, 0);
- // Now send the command (without subnet-id)
+ // Now send the command without subnet-id. Kea should select
+ // the subnet id on its own.
string txt =
"{\n"
" \"command\": \"lease6-add\",\n"
@@ -866,7 +892,8 @@ void Lease6CmdsTest::testLease6AddSubnetIdMissingBadAddr() {
checkLease6Stats(99, 0, 0, 0);
- // Now send the command (without subnet-id)
+ // Now send the command without subnet-id. Kea should select
+ // the subnet id on its own.
string txt =
"{\n"
" \"command\": \"lease6-add\",\n"
@@ -1016,6 +1043,7 @@ void Lease6CmdsTest::testLease6AddFullAddr() {
" \"fqdn-fwd\": true,\n"
" \"fqdn-rev\": true,\n"
" \"hostname\": \"urania.example.org\",\n"
+ " \"pool-id\": 5,\n"
" \"user-context\": { \"foobar\": true }\n"
" }\n"
"}";
@@ -1040,6 +1068,7 @@ void Lease6CmdsTest::testLease6AddFullAddr() {
EXPECT_EQ(true, l->fqdn_fwd_);
EXPECT_EQ(true, l->fqdn_rev_);
EXPECT_EQ("urania.example.org", l->hostname_);
+ EXPECT_EQ(5, l->pool_id_);
ASSERT_TRUE(l->getContext());
EXPECT_EQ("{ \"foobar\": true }", l->getContext()->str());
}
@@ -1075,93 +1104,102 @@ void Lease6CmdsTest::testLease6AddComment() {
Lease6Ptr l = lmptr_->getLease6(Lease::TYPE_NA, IOAddress("2001:db8:1::3"));
ASSERT_TRUE(l);
- // Make sure the lease have proper value set.
+ // Make sure the lease has proper value set.
+ ASSERT_TRUE(l->duid_);
+ EXPECT_EQ("1a:1b:1c:1d:1e:1f", l->duid_->toText());
ASSERT_TRUE(l->getContext());
EXPECT_EQ("{ \"comment\": \"a comment\" }", l->getContext()->str());
}
-void Lease6CmdsTest::testLease6GetByAddrNotFound() {
- // Initialize lease manager (true = v6, true = add leases)
- initLeaseMgr(true, true);
-
- // Now send the command.
- string cmd =
- "{\n"
- " \"command\": \"lease6-get\",\n"
- " \"arguments\": {"
- " \"subnet-id\": 1,\n"
- " \"ip-address\": \"2001:db8:1::10\"\n"
- " }\n"
- "}";
- string exp_rsp = "Lease not found.";
-
- // Note the status expected is empty. The query completed correctly,
- // just didn't found the lease.
- testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
-}
+void Lease6CmdsTest::testLease6AddExtendedInfo() {
+ // Initialize lease manager (true = v6, false = don't add leases)
+ initLeaseMgr(true, false);
-void Lease6CmdsTest::testLease6GetByClientIdInvalidType() {
- // Initialize lease manager (true = v6, true = add leases)
- initLeaseMgr(true, true);
+ checkLease6Stats(66, 0, 0, 0);
- // client-id query is allowed in v4 only.
- string cmd =
- "{\n"
- " \"command\": \"lease6-get\",\n"
- " \"arguments\": {"
- " \"identifier-type\": \"client-id\","
- " \"identifier\": \"01:02:03:04\","
- " \"subnet-id\": 44"
- " }\n"
- "}";
- string exp_rsp = "Query by client-id is not allowed in v6.";
- ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp);
-}
+ checkLease6Stats(99, 0, 0, 0);
-void Lease6CmdsTest::testLease6GetByDuidNotFound() {
- // Initialize lease manager (true = v6, true = add leases)
- initLeaseMgr(true, true);
+ Lease6Collection leases;
+ vector<uint8_t> remote_id = { 1, 2, 3, 4, 5, 6 };
+ leases = lmptr_->getLeases6ByRemoteId(remote_id,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ 0,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ LeasePageSize(10));
+ EXPECT_TRUE(leases.empty());
+ vector<uint8_t> relay_bin(8, 0x64);
+ DuidPtr relay_id(new DUID(relay_bin));
+ leases = lmptr_->getLeases6ByRelayId(*relay_id,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ 0,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ LeasePageSize(10));
+ EXPECT_TRUE(leases.empty());
// Now send the command.
- string cmd =
+ string txt =
"{\n"
- " \"command\": \"lease6-get\",\n"
+ " \"command\": \"lease6-add\",\n"
" \"arguments\": {"
- " \"subnet-id\": 1,\n"
- " \"identifier-type\": \"duid\","
- " \"identifier\": \"00:01:02:03:04:05:06:07\"\n"
+ " \"subnet-id\": 66,\n"
+ " \"ip-address\": \"2001:db8:1::1\",\n"
+ " \"iaid\": 7654321,\n"
+ " \"duid\": \"88:88:88:88:88:88:88:88\",\n"
+ " \"hostname\": \"newhostname.example.org\",\n"
+ " \"user-context\": { \"ISC\": { \"relay-info\": [ {\n"
+ " \"remote-id\": \"010203040506\",\n"
+ " \"relay-id\": \"6464646464646464\" } ] } }\n"
" }\n"
"}";
- string exp_rsp = "Lease not found.";
+ string exp_rsp = "Lease for address 2001:db8:1::1, subnet-id 66 added.";
+ testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
- // Note the status expected is empty. The query completed correctly,
- // just didn't found the lease.
- testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
-}
+ checkLease6Stats(66, 1, 0, 0);
-void Lease6CmdsTest::testLease6GetByAddr() {
- // Initialize lease manager (true = v6, true = add leases)
- initLeaseMgr(true, true);
+ checkLease6Stats(99, 0, 0, 0);
- // Now send the command.
- string cmd =
- "{\n"
- " \"command\": \"lease6-get\",\n"
- " \"arguments\": {\n"
- " \"ip-address\": \"2001:db8:1::1\"\n"
- " }\n"
- "}";
- string exp_rsp = "IPv6 lease found.";
+ // Now check that the lease is really there.
+ Lease6Ptr l = lmptr_->getLease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"));
+ ASSERT_TRUE(l);
- // The status expected is success. The lease should be returned.
- ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
- ASSERT_TRUE(rsp);
+ // Make sure the lease has proper value set.
+ ASSERT_TRUE(l->duid_);
+ EXPECT_EQ("88:88:88:88:88:88:88:88", l->duid_->toText());
+ EXPECT_EQ("newhostname.example.org", l->hostname_);
+ EXPECT_EQ(7654321, l->iaid_);
- ConstElementPtr lease = rsp->get("arguments");
- ASSERT_TRUE(lease);
+ // Check the user context / extended info too.
+ ConstElementPtr ctx = l->getContext();
+ ASSERT_TRUE(ctx);
+ string expected = "{ \"ISC\": { \"relay-info\": ";
+ expected += "[ { \"relay-id\": \"6464646464646464\", ";
+ expected += "\"remote-id\": \"010203040506\" } ] } }";
+ EXPECT_EQ(expected, ctx->str());
- // Now check that the lease was indeed returned.
- checkLease6(lease, "2001:db8:1::1", 0, 66, "42:42:42:42:42:42:42:42", false);
+ // Check that BLQ tables were updated.
+ leases = lmptr_->getLeases6ByRemoteId(remote_id,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ 0,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ LeasePageSize(10));
+ // The lease must be retrieved from the remote id table.
+ ASSERT_EQ(1, leases.size());
+ Lease6Ptr lx = leases[0];
+ ASSERT_TRUE(lx);
+ EXPECT_EQ(IOAddress("2001:db8:1::1"), lx->addr_);
+ EXPECT_EQ(*l, *lx);
+
+ // The lease must be retrieved from the relay id table.
+ leases = lmptr_->getLeases6ByRelayId(*relay_id,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ 0,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ LeasePageSize(10));
+ ASSERT_EQ(1, leases.size());
+ lx = leases[0];
+ ASSERT_TRUE(lx);
+ EXPECT_EQ(IOAddress("2001:db8:1::1"), lx->addr_);
+ EXPECT_EQ(*l, *lx);
}
void Lease6CmdsTest::testLease6GetMissingParams() {
@@ -1265,6 +1303,91 @@ void Lease6CmdsTest::testLease6GetByAddrBadParam() {
testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp);
}
+void Lease6CmdsTest::testLease6GetByAddrNotFound() {
+ // Initialize lease manager (true = v6, true = add leases)
+ initLeaseMgr(true, true);
+
+ // Invalid
+ string cmd =
+ "{\n"
+ " \"command\": \"lease6-get\",\n"
+ " \"arguments\": {"
+ " \"subnet-id\": 1,\n"
+ " \"ip-address\": \"2001:db8:1::10\"\n"
+ " }\n"
+ "}";
+ string exp_rsp = "Lease not found.";
+
+ // Note the status expected is empty. The query completed correctly,
+ // just didn't found the lease.
+ testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
+}
+
+void Lease6CmdsTest::testLease6GetByClientIdInvalidType() {
+ // Initialize lease manager (true = v6, true = add leases)
+ initLeaseMgr(true, true);
+
+ // client-id query is allowed in v4 only.
+ string cmd =
+ "{\n"
+ " \"command\": \"lease6-get\",\n"
+ " \"arguments\": {"
+ " \"identifier-type\": \"client-id\","
+ " \"identifier\": \"01:02:03:04\","
+ " \"subnet-id\": 44"
+ " }\n"
+ "}";
+ string exp_rsp = "Query by client-id is not allowed in v6.";
+ testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp);
+}
+
+void Lease6CmdsTest::testLease6GetByDuidNotFound() {
+ // Initialize lease manager (true = v6, true = add leases)
+ initLeaseMgr(true, true);
+
+ // Now send the command.
+ string cmd =
+ "{\n"
+ " \"command\": \"lease6-get\",\n"
+ " \"arguments\": {"
+ " \"subnet-id\": 1,\n"
+ " \"identifier-type\": \"duid\","
+ " \"identifier\": \"00:01:02:03:04:05:06:07\"\n"
+ " }\n"
+ "}";
+ string exp_rsp = "Lease not found.";
+
+ // Note the status expected is empty. The query completed correctly,
+ // just didn't found the lease.
+ testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
+}
+
+void Lease6CmdsTest::testLease6GetByAddr() {
+ // Initialize lease manager (true = v6, true = add leases)
+ initLeaseMgr(true, true);
+
+ // Now send the command.
+ string cmd =
+ "{\n"
+ " \"command\": \"lease6-get\",\n"
+ " \"arguments\": {\n"
+ " \"ip-address\": \"2001:db8:1::1\"\n"
+ " }\n"
+ "}";
+ string exp_rsp = "IPv6 lease found.";
+
+ // The status expected is success. The lease should be returned.
+ 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);
+
+ // Now check that the lease was indeed returned.
+ checkLease6(lease, "2001:db8:1::1", 0, 66, "42:42:42:42:42:42:42:42", false);
+}
void Lease6CmdsTest::testLease6GetByAddrPrefix() {
// Initialize lease manager (true = v6, false = don't add leases)
initLeaseMgr(true, false);
@@ -1290,6 +1413,8 @@ void Lease6CmdsTest::testLease6GetByAddrPrefix() {
// The status expected is success. The lease should be returned.
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");
@@ -1318,6 +1443,8 @@ void Lease6CmdsTest::testLease6GetByDuid() {
// The status expected is success. The lease should be returned.
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");
@@ -1352,7 +1479,7 @@ void Lease6CmdsTest::testLease6GetAll() {
// Let's check if the response contains desired leases.
checkLease6(leases, "2001:db8:1::1", 0, 66, "42:42:42:42:42:42:42:42", false);
- checkLease6(leases, "2001:db8:1::2", 0, 66, "56:56:56:56:56:56:56:56", false);
+ checkLease6(leases, "2001:db8:1::2", 0, 66, "56:56:56:56:56:56:56:56", false, 5);
checkLease6(leases, "2001:db8:2::1", 0, 99, "42:42:42:42:42:42:42:42", false);
checkLease6(leases, "2001:db8:2::2", 0, 99, "56:56:56:56:56:56:56:56", false);
}
@@ -1412,7 +1539,7 @@ void Lease6CmdsTest::testLease6GetAllBySubnetId() {
// Let's check if the response contains desired leases.
checkLease6(leases, "2001:db8:1::1", 0, 66, "42:42:42:42:42:42:42:42", false);
- checkLease6(leases, "2001:db8:1::2", 0, 66, "56:56:56:56:56:56:56:56", false);
+ checkLease6(leases, "2001:db8:1::2", 0, 66, "56:56:56:56:56:56:56:56", false, 5);
}
void Lease6CmdsTest::testLease6GetAllBySubnetIdNoLeases() {
@@ -1473,7 +1600,7 @@ void Lease6CmdsTest::testLease6GetAllByMultipleSubnetIds() {
// Let's check if the response contains desired leases.
checkLease6(leases, "2001:db8:1::1", 0, 66, "42:42:42:42:42:42:42:42", false);
- checkLease6(leases, "2001:db8:1::2", 0, 66, "56:56:56:56:56:56:56:56", false);
+ checkLease6(leases, "2001:db8:1::2", 0, 66, "56:56:56:56:56:56:56:56", false, 5);
checkLease6(leases, "2001:db8:2::1", 0, 99, "42:42:42:42:42:42:42:42", false);
checkLease6(leases, "2001:db8:2::2", 0, 99, "56:56:56:56:56:56:56:56", false);
}
@@ -1590,8 +1717,12 @@ void Lease6CmdsTest::testLease6GetPaged() {
Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
IOAddress(last_address));
ASSERT_TRUE(from_mgr);
+ uint32_t pool_id = 0;
+ if (last_address == "2001:db8:1::2") {
+ pool_id = 5;
+ }
checkLease6(leases, last_address, 0, from_mgr->subnet_id_,
- from_mgr->duid_->toText(), false);
+ from_mgr->duid_->toText(), false, pool_id);
}
} else {
@@ -1888,7 +2019,7 @@ void Lease6CmdsTest::testLease6UpdateMissingParams() {
// Initialize lease manager (true = v6, true = add leases)
initLeaseMgr(true, true);
- // Everything missing. What sort of crap is that?
+ // Everything missing. What sort of nonsense is that?
string txt =
"{\n"
" \"command\": \"lease6-update\",\n"
@@ -1899,7 +2030,7 @@ void Lease6CmdsTest::testLease6UpdateMissingParams() {
testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
// Just ip is not enough (subnet-id and duid missing, although
- // kea should be able to figure out the subnet-id on its own.
+ // Kea should be able to figure out the subnet-id on its own.
txt =
"{\n"
" \"command\": \"lease6-update\",\n"
@@ -1992,7 +2123,7 @@ void Lease6CmdsTest::testLease6UpdateBadParams() {
exp_rsp = "The address 3000::1 does not belong to subnet 2001:db8:1::/48, subnet-id=66";
testCommand(txt, CONTROL_RESULT_CONFLICT, exp_rsp);
- // Nope, can't do v4 address in v6 lease.
+ // v4? You're a time traveler from early 80s or what?
txt =
"{\n"
" \"command\": \"lease6-update\",\n"
@@ -2055,13 +2186,13 @@ void Lease6CmdsTest::testLease6UpdateBadParams() {
testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
}
-void Lease6CmdsTest::testLease6Update() {
- // Initialize lease manager (true = v6, true = add leases)
- initLeaseMgr(true, true);
+void Lease6CmdsTest::testLease6UpdateNoLease() {
+ // Initialize lease manager (true = v6, false = don't add leases)
+ initLeaseMgr(true, false);
- checkLease6Stats(66, 2, 0, 0);
+ checkLease6Stats(66, 0, 0, 0);
- checkLease6Stats(99, 2, 0, 0);
+ checkLease6Stats(99, 0, 0, 0);
// Now send the command.
string txt =
@@ -2075,26 +2206,17 @@ void Lease6CmdsTest::testLease6Update() {
" \"hostname\": \"newhostname.example.org\""
" }\n"
"}";
- string exp_rsp = "IPv6 lease updated.";
- testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
-
- checkLease6Stats(66, 2, 0, 0);
-
- checkLease6Stats(99, 2, 0, 0);
+ string exp_rsp = "failed to update the lease with address 2001:db8:1::1 "
+ "either because the lease has been deleted or it has changed in the "
+ "database, in both cases a retry might succeed";
+ testCommand(txt, CONTROL_RESULT_CONFLICT, exp_rsp);
- // Now check that the lease is really there.
- Lease6Ptr l = lmptr_->getLease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"));
- ASSERT_TRUE(l);
+ checkLease6Stats(66, 0, 0, 0);
- // Make sure the lease has been updated.
- ASSERT_TRUE(l->duid_);
- EXPECT_EQ("88:88:88:88:88:88:88:88", l->duid_->toText());
- EXPECT_EQ("newhostname.example.org", l->hostname_);
- EXPECT_EQ(7654321, l->iaid_);
- EXPECT_FALSE(l->getContext());
+ checkLease6Stats(99, 0, 0, 0);
}
-void Lease6CmdsTest::testLease6UpdateExtendedInfo() {
+void Lease6CmdsTest::testLease6Update() {
// Initialize lease manager (true = v6, true = add leases)
initLeaseMgr(true, true);
@@ -2102,23 +2224,6 @@ void Lease6CmdsTest::testLease6UpdateExtendedInfo() {
checkLease6Stats(99, 2, 0, 0);
- Lease6Collection leases;
- vector<uint8_t> remote_id = { 1, 2, 3, 4, 5, 6 };
- leases = lmptr_->getLeases6ByRemoteId(remote_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
- IOAddress::IPV6_ZERO_ADDRESS(),
- LeasePageSize(10));
- EXPECT_TRUE(leases.empty());
- vector<uint8_t> relay_bin(8, 0x64);
- DuidPtr relay_id(new DUID(relay_bin));
- leases = lmptr_->getLeases6ByRelayId(*relay_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
- IOAddress::IPV6_ZERO_ADDRESS(),
- LeasePageSize(10));
- EXPECT_TRUE(leases.empty());
-
// Now send the command.
string txt =
"{\n"
@@ -2128,10 +2233,8 @@ void Lease6CmdsTest::testLease6UpdateExtendedInfo() {
" \"ip-address\": \"2001:db8:1::1\",\n"
" \"iaid\": 7654321,\n"
" \"duid\": \"88:88:88:88:88:88:88:88\",\n"
- " \"hostname\": \"newhostname.example.org\",\n"
- " \"user-context\": { \"ISC\": { \"relay-info\": [ {\n"
- " \"remote-id\": \"010203040506\",\n"
- " \"relay-id\": \"6464646464646464\" } ] } }\n"
+ " \"pool-id\": 3,\n"
+ " \"hostname\": \"newhostname.example.org\""
" }\n"
"}";
string exp_rsp = "IPv6 lease updated.";
@@ -2148,41 +2251,10 @@ void Lease6CmdsTest::testLease6UpdateExtendedInfo() {
// Make sure the lease has been updated.
ASSERT_TRUE(l->duid_);
EXPECT_EQ("88:88:88:88:88:88:88:88", l->duid_->toText());
+ EXPECT_EQ(3, l->pool_id_);
EXPECT_EQ("newhostname.example.org", l->hostname_);
EXPECT_EQ(7654321, l->iaid_);
-
- // Check the user context / extended info too.
- ConstElementPtr ctx = l->getContext();
- ASSERT_TRUE(ctx);
- string expected = "{ \"ISC\": { \"relay-info\": ";
- expected += "[ { \"relay-id\": \"6464646464646464\", ";
- expected += "\"remote-id\": \"010203040506\" } ] } }";
- EXPECT_EQ(expected, ctx->str());
-
- // Check that BLQ tables were updated.
- leases = lmptr_->getLeases6ByRemoteId(remote_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
- IOAddress::IPV6_ZERO_ADDRESS(),
- LeasePageSize(10));
- // The lease must be retrieved from the remote id table.
- ASSERT_EQ(1, leases.size());
- Lease6Ptr lx = leases[0];
- ASSERT_TRUE(lx);
- EXPECT_EQ(IOAddress("2001:db8:1::1"), lx->addr_);
- EXPECT_EQ(*l, *lx);
-
- // The lease must be retrieved from the relay id table.
- leases = lmptr_->getLeases6ByRelayId(*relay_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
- IOAddress::IPV6_ZERO_ADDRESS(),
- LeasePageSize(10));
- ASSERT_EQ(1, leases.size());
- lx = leases[0];
- ASSERT_TRUE(lx);
- EXPECT_EQ(IOAddress("2001:db8:1::1"), lx->addr_);
- EXPECT_EQ(*l, *lx);
+ EXPECT_FALSE(l->getContext());
}
void Lease6CmdsTest::testLease6UpdateDeclinedLeases() {
@@ -2202,6 +2274,7 @@ void Lease6CmdsTest::testLease6UpdateDeclinedLeases() {
" \"ip-address\": \"2001:db8:1::1\",\n"
" \"iaid\": 7654321,\n"
" \"duid\": \"88:88:88:88:88:88:88:88\",\n"
+ " \"pool-id\": 3,\n"
" \"hostname\": \"newhostname.example.org\""
" }\n"
"}";
@@ -2212,13 +2285,14 @@ void Lease6CmdsTest::testLease6UpdateDeclinedLeases() {
checkLease6Stats(99, 2, 2, 0);
- // Now check that the lease is really there.
+ // Now check that the lease is still there.
Lease6Ptr l = lmptr_->getLease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"));
ASSERT_TRUE(l);
// Make sure the lease has been updated.
ASSERT_TRUE(l->duid_);
EXPECT_EQ("88:88:88:88:88:88:88:88", l->duid_->toText());
+ EXPECT_EQ(3, l->pool_id_);
EXPECT_EQ("newhostname.example.org", l->hostname_);
EXPECT_EQ(7654321, l->iaid_);
EXPECT_FALSE(l->getContext());
@@ -2250,7 +2324,7 @@ void Lease6CmdsTest::testLease6UpdateNoSubnetId() {
checkLease6Stats(99, 2, 0, 0);
- // Now check that the lease is really there.
+ // Now check that the lease is still there.
Lease6Ptr l = lmptr_->getLease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"));
ASSERT_TRUE(l);
@@ -2306,81 +2380,6 @@ void Lease6CmdsTest::testLease6UpdateNoSubnetIdDeclinedLeases() {
EXPECT_FALSE(l->getContext());
}
-void Lease6CmdsTest::testLease6UpdateComment() {
- // Initialize lease manager (true = v6, true = add leases)
- initLeaseMgr(true, true);
-
- checkLease6Stats(66, 2, 0, 0);
-
- checkLease6Stats(99, 2, 0, 0);
-
- // Now send the command.
- string txt =
- "{\n"
- " \"command\": \"lease6-update\",\n"
- " \"arguments\": {"
- " \"subnet-id\": 66,\n"
- " \"ip-address\": \"2001:db8:1::1\",\n"
- " \"iaid\": 42,\n"
- " \"duid\": \"42:42:42:42:42:42:42:42\",\n"
- " \"comment\": \"a comment\",\n"
- " \"user-context\": { \"foobar\": true }\n"
- " }\n"
- "}";
- string exp_rsp = "IPv6 lease updated.";
- testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
-
- checkLease6Stats(66, 2, 0, 0);
-
- checkLease6Stats(99, 2, 0, 0);
-
- // Now check that the lease is really there.
- Lease6Ptr l = lmptr_->getLease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"));
- ASSERT_TRUE(l);
-
- // Make sure the lease has been updated.
- ASSERT_TRUE(l->duid_);
-
- // Check user context.
- ConstElementPtr ctx = l->getContext();
- ASSERT_TRUE(ctx);
- EXPECT_EQ(2, ctx->size());
- ASSERT_TRUE(ctx->contains("comment"));
- EXPECT_EQ("\"a comment\"", ctx->get("comment")->str());
- ASSERT_TRUE(ctx->contains("foobar"));
- EXPECT_EQ("true", ctx->get("foobar")->str());
-}
-
-void Lease6CmdsTest::testLease6UpdateNoLease() {
- // Initialize lease manager (true = v6, false = don't add leases)
- initLeaseMgr(true, false);
-
- checkLease6Stats(66, 0, 0, 0);
-
- checkLease6Stats(99, 0, 0, 0);
-
- // Now send the command.
- string txt =
- "{\n"
- " \"command\": \"lease6-update\",\n"
- " \"arguments\": {"
- " \"subnet-id\": 66,\n"
- " \"ip-address\": \"2001:db8:1::1\",\n"
- " \"iaid\": 7654321,\n"
- " \"duid\": \"88:88:88:88:88:88:88:88\",\n"
- " \"hostname\": \"newhostname.example.org\""
- " }\n"
- "}";
- string exp_rsp = "failed to update the lease with address 2001:db8:1::1 "
- "either because the lease has been deleted or it has changed in the "
- "database, in both cases a retry might succeed";
- testCommand(txt, CONTROL_RESULT_CONFLICT, exp_rsp);
-
- checkLease6Stats(66, 0, 0, 0);
-
- checkLease6Stats(99, 0, 0, 0);
-}
-
void Lease6CmdsTest::testLease6UpdateForceCreate() {
// Initialize lease manager (true = v6, false = don't add leases)
initLeaseMgr(true, false);
@@ -2494,6 +2493,143 @@ void Lease6CmdsTest::testLease6UpdateDoNotForceCreate() {
checkLease6Stats(99, 0, 0, 0);
}
+void Lease6CmdsTest::testLease6UpdateComment() {
+ // Initialize lease manager (true = v6, true = add leases)
+ initLeaseMgr(true, true);
+
+ checkLease6Stats(66, 2, 0, 0);
+
+ checkLease6Stats(99, 2, 0, 0);
+
+ // Now send the command.
+ string txt =
+ "{\n"
+ " \"command\": \"lease6-update\",\n"
+ " \"arguments\": {"
+ " \"subnet-id\": 66,\n"
+ " \"ip-address\": \"2001:db8:1::1\",\n"
+ " \"iaid\": 42,\n"
+ " \"duid\": \"42:42:42:42:42:42:42:42\",\n"
+ " \"comment\": \"a comment\",\n"
+ " \"user-context\": { \"foobar\": true }\n"
+ " }\n"
+ "}";
+ string exp_rsp = "IPv6 lease updated.";
+ testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
+
+ checkLease6Stats(66, 2, 0, 0);
+
+ checkLease6Stats(99, 2, 0, 0);
+
+ // Now check that the lease is really there.
+ Lease6Ptr l = lmptr_->getLease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"));
+ ASSERT_TRUE(l);
+
+ // Make sure the lease has been updated.
+ ASSERT_TRUE(l->duid_);
+ EXPECT_EQ("42:42:42:42:42:42:42:42", l->duid_->toText());
+
+ // Check user context.
+ ConstElementPtr ctx = l->getContext();
+ ASSERT_TRUE(ctx);
+ EXPECT_EQ(2, ctx->size());
+ ASSERT_TRUE(ctx->contains("comment"));
+ EXPECT_EQ("\"a comment\"", ctx->get("comment")->str());
+ ASSERT_TRUE(ctx->contains("foobar"));
+ EXPECT_EQ("true", ctx->get("foobar")->str());
+}
+
+void Lease6CmdsTest::testLease6UpdateExtendedInfo() {
+ // Initialize lease manager (true = v6, true = add leases)
+ initLeaseMgr(true, true);
+
+ checkLease6Stats(66, 2, 0, 0);
+
+ checkLease6Stats(99, 2, 0, 0);
+
+ Lease6Collection leases;
+ vector<uint8_t> remote_id = { 1, 2, 3, 4, 5, 6 };
+ leases = lmptr_->getLeases6ByRemoteId(remote_id,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ 0,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ LeasePageSize(10));
+ EXPECT_TRUE(leases.empty());
+ vector<uint8_t> relay_bin(8, 0x64);
+ DuidPtr relay_id(new DUID(relay_bin));
+ leases = lmptr_->getLeases6ByRelayId(*relay_id,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ 0,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ LeasePageSize(10));
+ EXPECT_TRUE(leases.empty());
+
+ // Now send the command.
+ string txt =
+ "{\n"
+ " \"command\": \"lease6-update\",\n"
+ " \"arguments\": {"
+ " \"subnet-id\": 66,\n"
+ " \"ip-address\": \"2001:db8:1::1\",\n"
+ " \"iaid\": 7654321,\n"
+ " \"duid\": \"88:88:88:88:88:88:88:88\",\n"
+ " \"hostname\": \"newhostname.example.org\",\n"
+ " \"user-context\": { \"ISC\": { \"relay-info\": [ {\n"
+ " \"remote-id\": \"010203040506\",\n"
+ " \"relay-id\": \"6464646464646464\" } ] } }\n"
+ " }\n"
+ "}";
+ string exp_rsp = "IPv6 lease updated.";
+ testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
+
+ checkLease6Stats(66, 2, 0, 0);
+
+ checkLease6Stats(99, 2, 0, 0);
+
+ // Now check that the lease is really there.
+ Lease6Ptr l = lmptr_->getLease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"));
+ ASSERT_TRUE(l);
+
+ // Make sure the lease has been updated.
+ ASSERT_TRUE(l->duid_);
+ EXPECT_EQ("88:88:88:88:88:88:88:88", l->duid_->toText());
+ EXPECT_EQ("newhostname.example.org", l->hostname_);
+ EXPECT_EQ(7654321, l->iaid_);
+
+ // Check the user context / extended info too.
+ ConstElementPtr ctx = l->getContext();
+ ASSERT_TRUE(ctx);
+ string expected = "{ \"ISC\": { \"relay-info\": ";
+ expected += "[ { \"relay-id\": \"6464646464646464\", ";
+ expected += "\"remote-id\": \"010203040506\" } ] } }";
+ EXPECT_EQ(expected, ctx->str());
+
+ // Check that BLQ tables were updated.
+ leases = lmptr_->getLeases6ByRemoteId(remote_id,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ 0,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ LeasePageSize(10));
+ // The lease must be retrieved from the remote id table.
+ ASSERT_EQ(1, leases.size());
+ Lease6Ptr lx = leases[0];
+ ASSERT_TRUE(lx);
+ EXPECT_EQ(IOAddress("2001:db8:1::1"), lx->addr_);
+ EXPECT_EQ(*l, *lx);
+
+ // The lease must be retrieved from the relay id table.
+ leases = lmptr_->getLeases6ByRelayId(*relay_id,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ 0,
+ IOAddress::IPV6_ZERO_ADDRESS(),
+ LeasePageSize(10));
+ ASSERT_EQ(1, leases.size());
+ lx = leases[0];
+ ASSERT_TRUE(lx);
+ EXPECT_EQ(IOAddress("2001:db8:1::1"), lx->addr_);
+ EXPECT_EQ(*l, *lx);
+}
+
void Lease6CmdsTest::testLease6DelMissingParams() {
// No parameters whatsoever. You want just a lease, any lease?
string cmd =
@@ -2692,6 +2828,10 @@ void Lease6CmdsTest::testLease6DelByAddrBadParam() {
// Initialize lease manager (true = v6, true = add leases)
initLeaseMgr(true, true);
+ checkLease6Stats(66, 2, 0, 0);
+
+ checkLease6Stats(99, 2, 0, 0);
+
// Invalid family
string cmd =
"{\n"
@@ -2703,6 +2843,10 @@ void Lease6CmdsTest::testLease6DelByAddrBadParam() {
string exp_rsp = "Invalid IPv6 address specified: 192.0.2.1";
testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp);
+ checkLease6Stats(66, 2, 0, 0);
+
+ checkLease6Stats(99, 2, 0, 0);
+
// This is way off
cmd =
"{\n"
@@ -3510,7 +3654,7 @@ void Lease6CmdsTest::testLease6ResendDdnsNoLease() {
" }\n"
"}\n";
string exp_rsp = "No lease found for: 2001::dead:beef";
- ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
+ testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
}
void Lease6CmdsTest::testLease6ResendNoHostname() {
@@ -3777,6 +3921,7 @@ void Lease6CmdsTest::testLease6DnsRemoveD2Disabled() {
ASSERT_FALSE(lease);
}
+// Verify that v4 lease add handles conflict as expected.
void Lease6CmdsTest::testLease6ConflictingAdd() {
MultiThreadingTest mt(true);
@@ -3825,7 +3970,7 @@ void Lease6CmdsTest::testLease6ConflictingUpdate() {
// Initialize lease manager (true = v6, true = add leases)
initLeaseMgr(true, true);
- // Verify lease stats show leases.
+ // Verify stats show no leases.
checkLease6Stats(66, 2, 0, 0);
// Make sure the lease exists.
@@ -3930,6 +4075,9 @@ void Lease6CmdsTest::testLease6ConflictingBulkApplyAdd() {
}
void Lease6CmdsTest::testLease6Write() {
+ // lease4-write negative tests. Positive tests are in the
+ // memfile_lease_mgr_unittest.cc file.
+
// Initialize lease manager (true = v6, false = don't add leases)
initLeaseMgr(true, false);
@@ -4083,6 +4231,33 @@ TEST_F(Lease6CmdsTest, lease6AddCommentMultiThreading) {
testLease6AddComment();
}
+TEST_F(Lease6CmdsTest, lease6AddExtendedInfo) {
+ testLease6AddExtendedInfo();
+}
+
+TEST_F(Lease6CmdsTest, lease6AddExtendedInfoMultiThreading) {
+ MultiThreadingTest mt(true);
+ testLease6AddExtendedInfo();
+}
+
+TEST_F(Lease6CmdsTest, lease6GetMissingParams) {
+ testLease6GetMissingParams();
+}
+
+TEST_F(Lease6CmdsTest, lease6GetMissingParamsMultiThreading) {
+ MultiThreadingTest mt(true);
+ testLease6GetMissingParams();
+}
+
+TEST_F(Lease6CmdsTest, lease6GetByAddrBadParam) {
+ testLease6GetByAddrBadParam();
+}
+
+TEST_F(Lease6CmdsTest, lease6GetByAddrBadParamMultiThreading) {
+ MultiThreadingTest mt(true);
+ testLease6GetByAddrBadParam();
+}
+
TEST_F(Lease6CmdsTest, lease6GetByAddrNotFound) {
testLease6GetByAddrNotFound();
}
@@ -4119,24 +4294,6 @@ TEST_F(Lease6CmdsTest, lease6GetByAddrMultiThreading) {
testLease6GetByAddr();
}
-TEST_F(Lease6CmdsTest, lease6GetMissingParams) {
- testLease6GetMissingParams();
-}
-
-TEST_F(Lease6CmdsTest, lease6GetMissingParamsMultiThreading) {
- MultiThreadingTest mt(true);
- testLease6GetMissingParams();
-}
-
-TEST_F(Lease6CmdsTest, lease6GetByAddrBadParam) {
- testLease6GetByAddrBadParam();
-}
-
-TEST_F(Lease6CmdsTest, lease6GetByAddrBadParamMultiThreading) {
- MultiThreadingTest mt(true);
- testLease6GetByAddrBadParam();
-}
-
TEST_F(Lease6CmdsTest, lease6GetByAddrPrefix) {
testLease6GetByAddrPrefix();
}
@@ -4344,12 +4501,17 @@ TEST_F(Lease6CmdsTest, lease6UpdateBadParamsMultiThreading) {
testLease6UpdateBadParams();
}
-TEST_F(Lease6CmdsTest, lease6Update) {
- testLease6Update();
+TEST_F(Lease6CmdsTest, lease6UpdateNoLease) {
+ testLease6UpdateNoLease();
}
-TEST_F(Lease6CmdsTest, lease6UpdateExtendedInfo) {
- testLease6UpdateExtendedInfo();
+TEST_F(Lease6CmdsTest, lease6UpdateNoLeaseMultiThreading) {
+ MultiThreadingTest mt(true);
+ testLease6UpdateNoLease();
+}
+
+TEST_F(Lease6CmdsTest, lease6Update) {
+ testLease6Update();
}
TEST_F(Lease6CmdsTest, lease6UpdateMultiThreading) {
@@ -4393,13 +4555,13 @@ TEST_F(Lease6CmdsTest, lease6UpdateCommentMultiThreading) {
testLease6UpdateComment();
}
-TEST_F(Lease6CmdsTest, lease6UpdateNoLease) {
- testLease6UpdateNoLease();
+TEST_F(Lease6CmdsTest, lease6UpdateExtendedInfo) {
+ testLease6UpdateExtendedInfo();
}
-TEST_F(Lease6CmdsTest, lease6UpdateNoLeaseMultiThreading) {
+TEST_F(Lease6CmdsTest, lease6UpdateExtendedInfoMultiThreading) {
MultiThreadingTest mt(true);
- testLease6UpdateNoLease();
+ testLease6UpdateExtendedInfo();
}
TEST_F(Lease6CmdsTest, lease6UpdateForceCreate) {
diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.h b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.h
index b8da1f94d4..6332ef7dc3 100644
--- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.h
+++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.h
@@ -311,7 +311,7 @@ public:
const isc::dhcp::SubnetID& subnet_id,
const uint8_t hw_address_pattern,
const uint8_t client_id_pattern,
- bool declined = false) {
+ bool declined = false, uint32_t pool_id = 0) {
isc::dhcp::Lease4Ptr lease(new isc::dhcp::Lease4());
lease->addr_ = isc::asiolink::IOAddress(ip_address);
@@ -331,6 +331,7 @@ public:
lease->fqdn_fwd_ = false;
lease->fqdn_rev_ = true;
lease->hostname_ = "myhost.example.com.";
+ lease->pool_id_ = pool_id;
return (lease);
}
@@ -351,7 +352,7 @@ public:
isc::dhcp::Lease6Ptr createLease6(const std::string& ip_address,
const isc::dhcp::SubnetID& subnet_id,
const uint8_t duid_pattern,
- bool declined = false) {
+ bool declined = false, uint32_t pool_id = 0) {
isc::dhcp::Lease6Ptr lease(new isc::dhcp::Lease6());
lease->addr_ = isc::asiolink::IOAddress(ip_address);
@@ -372,6 +373,7 @@ public:
lease->fqdn_fwd_ = false;
lease->fqdn_rev_ = true;
lease->hostname_ = "myhost.example.com.";
+ lease->pool_id_ = pool_id;
return (lease);
}
@@ -393,7 +395,7 @@ public:
if (v6) {
s << "universe=6 extended-info-tables=true";
} else {
- s << "universe=4";
+ s << "universe=4";
}
isc::dhcp::LeaseMgrFactory::create(s.str());
@@ -420,7 +422,7 @@ public:
if (insert_lease) {
if (v6) {
lmptr_->addLease(createLease6("2001:db8:1::1", 66, 0x42, declined));
- lmptr_->addLease(createLease6("2001:db8:1::2", 66, 0x56, declined));
+ lmptr_->addLease(createLease6("2001:db8:1::2", 66, 0x56, declined, 5));
lmptr_->addLease(createLease6("2001:db8:2::1", 99, 0x42, declined));
lmptr_->addLease(createLease6("2001:db8:2::2", 99, 0x56, declined));
if (declined) {
@@ -446,7 +448,7 @@ public:
int64_t(2));
} else {
lmptr_->addLease(createLease4("192.0.2.1", 44, 0x08, 0x42, declined));
- lmptr_->addLease(createLease4("192.0.2.2", 44, 0x09, 0x56, declined));
+ lmptr_->addLease(createLease4("192.0.2.2", 44, 0x09, 0x56, declined, 5));
lmptr_->addLease(createLease4("192.0.3.1", 88, 0x08, 0x42, declined));
lmptr_->addLease(createLease4("192.0.3.2", 88, 0x09, 0x56, declined));
if (declined) {
diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc
index 61bbe614b0..c96a34317c 100644
--- a/src/lib/dhcpsrv/alloc_engine.cc
+++ b/src/lib/dhcpsrv/alloc_engine.cc
@@ -1793,7 +1793,7 @@ AllocEngine::reuseExpiredLease(Lease6Ptr& expired, ClientContext6& ctx,
}
if (!ctx.fake_allocation_) {
- // Add(update) the extended information on the lease.
+ // Add (update) the extended information on the lease.
updateLease6ExtendedInfo(expired, ctx);
const auto& pool = ctx.subnet_->getPool(ctx.currentIA().type_, expired->addr_, false);
@@ -1986,7 +1986,7 @@ Lease6Ptr AllocEngine::createLease6(ClientContext6& ctx,
}
if (!ctx.fake_allocation_) {
- // Add(update) the extended information on the lease.
+ // Add (update) the extended information on the lease.
updateLease6ExtendedInfo(lease, ctx);
const auto& pool = ctx.subnet_->getPool(ctx.currentIA().type_, lease->addr_, false);
@@ -4237,7 +4237,7 @@ AllocEngine::createLease4(const ClientContext4& ctx, const IOAddress& addr,
lease->fqdn_rev_ = ctx.rev_dns_update_;
lease->hostname_ = ctx.hostname_;
- // Add(update) the extended information on the lease.
+ // Add (update) the extended information on the lease.
static_cast<void>(updateLease4ExtendedInfo(lease, ctx));
// Let's execute all callouts registered for lease4_select
@@ -4910,7 +4910,7 @@ AllocEngine::updateLease4Information(const Lease4Ptr& lease,
lease->hostname_ = ctx.hostname_;
}
- // Add(update) the extended information on the lease.
+ // Add (update) the extended information on the lease.
if (updateLease4ExtendedInfo(lease, ctx)) {
changed = true;
}
diff --git a/src/lib/dhcpsrv/lease.cc b/src/lib/dhcpsrv/lease.cc
index 58cc495207..b8bf3531d2 100644
--- a/src/lib/dhcpsrv/lease.cc
+++ b/src/lib/dhcpsrv/lease.cc
@@ -186,7 +186,7 @@ Lease::fromElementCommon(const LeasePtr& lease, const data::ConstElementPtr& ele
isc_throw(BadValue, "pool-id is not an integer");
}
- if (pool_id->intValue() < 0) {
+ if (pool_id->intValue() <= 0) {
isc_throw(BadValue, "pool-id " << pool_id->intValue() << " is not"
<< " a positive integer");
} else if (pool_id->intValue() > numeric_limits<uint32_t>::max()) {
@@ -386,7 +386,9 @@ Lease4::toElement() const {
contextToElement(map);
map->set("ip-address", Element::create(addr_.toText()));
map->set("subnet-id", Element::create(static_cast<long int>(subnet_id_)));
- map->set("pool-id", Element::create(static_cast<long int>(pool_id_)));
+ if (pool_id_) {
+ map->set("pool-id", Element::create(static_cast<long int>(pool_id_)));
+ }
map->set("hw-address", Element::create(hwaddr_->toText(false)));
if (client_id_) {
@@ -617,7 +619,9 @@ Lease6::toElement() const {
map->set("iaid", Element::create(static_cast<long int>(iaid_)));
map->set("duid", Element::create(duid_->toText()));
map->set("subnet-id", Element::create(static_cast<long int>(subnet_id_)));
- map->set("pool-id", Element::create(static_cast<long int>(pool_id_)));
+ if (pool_id_) {
+ map->set("pool-id", Element::create(static_cast<long int>(pool_id_)));
+ }
map->set("cltt", Element::create(cltt_));
map->set("preferred-lft", Element::create(static_cast<long int>(preferred_lft_)));
diff --git a/src/lib/dhcpsrv/lease_mgr.h b/src/lib/dhcpsrv/lease_mgr.h
index 4b84ae3cbc..4b5ea99007 100644
--- a/src/lib/dhcpsrv/lease_mgr.h
+++ b/src/lib/dhcpsrv/lease_mgr.h
@@ -99,7 +99,7 @@ struct LeaseStatsRow {
}
/// @brief Less-than operator
- bool operator< (const LeaseStatsRow &rhs) const {
+ bool operator<(const LeaseStatsRow &rhs) const {
if (subnet_id_ < rhs.subnet_id_) {
return (true);
}
diff --git a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc
index a452accd85..1e2735c522 100644
--- a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc
@@ -126,6 +126,7 @@ GenericLeaseMgrTest::initializeLease4(std::string address) {
lease->fqdn_rev_ = true;
lease->fqdn_fwd_ = true;
lease->hostname_ = "myhost.example.com.";
+ lease->pool_id_ = 7;
} else if (address == straddress4_[2]) {
lease->hwaddr_.reset(new HWAddr(vector<uint8_t>(6, 0x2a), HTYPE_ETHER));
@@ -254,6 +255,7 @@ GenericLeaseMgrTest::initializeLease6(std::string address) {
lease->fqdn_fwd_ = false;
lease->fqdn_rev_ = true;
lease->hostname_ = "myhost.example.com.";
+ lease->pool_id_ = 7;
} else if (address == straddress6_[2]) {
lease->type_ = leasetype6_[2];
@@ -3127,6 +3129,7 @@ GenericLeaseMgrTest::testRecountLeaseStats6() {
cfg->add(subnet);
ASSERT_NO_THROW(CfgMgr::instance().commit());
+
// Create the expected stats list. At this point, the only stat
// that should be non-zero is total-nas/total-pds.
for (int i = 0; i < num_subnets; ++i) {
diff --git a/src/lib/dhcpsrv/tests/lease_unittest.cc b/src/lib/dhcpsrv/tests/lease_unittest.cc
index b63131b888..0ed815ade4 100644
--- a/src/lib/dhcpsrv/tests/lease_unittest.cc
+++ b/src/lib/dhcpsrv/tests/lease_unittest.cc
@@ -422,7 +422,6 @@ TEST_F(Lease4Test, toElement) {
"\"ip-address\": \"192.0.2.3\","
"\"state\": 0,"
"\"subnet-id\": 789,"
- "\"pool-id\": 0,"
"\"user-context\": { \"foobar\": 1234 },"
"\"valid-lft\": 3600 "
"}";
@@ -432,6 +431,7 @@ TEST_F(Lease4Test, toElement) {
// Now let's try with a lease without client-id and user context.
lease.client_id_.reset();
lease.setContext(ConstElementPtr());
+ lease.pool_id_ = 5;
expected = "{"
"\"cltt\": 12345678,"
@@ -442,7 +442,7 @@ TEST_F(Lease4Test, toElement) {
"\"ip-address\": \"192.0.2.3\","
"\"state\": 0,"
"\"subnet-id\": 789,"
- "\"pool-id\": 0,"
+ "\"pool-id\": 5,"
"\"valid-lft\": 3600 "
"}";
@@ -461,7 +461,7 @@ TEST_F(Lease4Test, toElement) {
"\"ip-address\": \"192.0.2.3\","
"\"state\": 0,"
"\"subnet-id\": 789,"
- "\"pool-id\": 0,"
+ "\"pool-id\": 5,"
"\"valid-lft\": 3600 "
"}";
@@ -546,6 +546,7 @@ TEST_F(Lease4Test, fromElementInvalidValues) {
testInvalidElement<Lease4>(json, "subnet-id", 0x100000000, false);
testInvalidElement<Lease4>(json, "pool-id", std::string("xyz"), false);
testInvalidElement<Lease4>(json, "pool-id", -5, false);
+ testInvalidElement<Lease4>(json, "pool-id", 0, false);
testInvalidElement<Lease4>(json, "pool-id", 0x100000000, false);
testInvalidElement<Lease4>(json, "valid-lft", std::string("xyz"));
testInvalidElement<Lease4>(json, "valid-lft", -3, false);
@@ -1015,7 +1016,6 @@ TEST(Lease6Test, toElementAddress) {
"\"preferred-lft\": 400,"
"\"state\": 1,"
"\"subnet-id\": 5678,"
- "\"pool-id\": 0,"
"\"type\": \"IA_NA\","
"\"user-context\": { \"foobar\": 1234 },"
"\"valid-lft\": 800"
@@ -1026,6 +1026,7 @@ TEST(Lease6Test, toElementAddress) {
// Now let's try with a lease without hardware address and user context.
lease.hwaddr_.reset();
lease.setContext(ConstElementPtr());
+ lease.pool_id_ = 5;
expected = "{"
"\"cltt\": 12345678,"
@@ -1038,7 +1039,7 @@ TEST(Lease6Test, toElementAddress) {
"\"preferred-lft\": 400,"
"\"state\": 1,"
"\"subnet-id\": 5678,"
- "\"pool-id\": 0,"
+ "\"pool-id\": 5,"
"\"type\": \"IA_NA\","
"\"valid-lft\": 800"
"}";
@@ -1060,7 +1061,7 @@ TEST(Lease6Test, toElementAddress) {
"\"preferred-lft\": 400,"
"\"state\": 1,"
"\"subnet-id\": 5678,"
- "\"pool-id\": 0,"
+ "\"pool-id\": 5,"
"\"type\": \"IA_NA\","
"\"valid-lft\": 800"
"}";
@@ -1117,9 +1118,6 @@ TEST(Lease6Test, toElementPrefix) {
ASSERT_TRUE(l->contains("subnet-id"));
EXPECT_EQ(5678, l->get("subnet-id")->intValue());
- ASSERT_TRUE(l->contains("pool-id"));
- EXPECT_EQ(0, l->get("pool-id")->intValue());
-
ASSERT_TRUE(l->contains("state"));
EXPECT_EQ(static_cast<int>(Lease::STATE_DEFAULT),
l->get("state")->intValue());
@@ -1136,15 +1134,23 @@ TEST(Lease6Test, toElementPrefix) {
ASSERT_TRUE(l->contains("user-context"));
EXPECT_EQ("{ \"foobar\": 1234 }", l->get("user-context")->str());
+ ASSERT_FALSE(l->contains("pool-id"));
+
// Now let's try with a lease without hardware address or user context.
lease.hwaddr_.reset();
lease.setContext(ConstElementPtr());
+ lease.pool_id_ = 5;
+
l = lease.toElement();
EXPECT_FALSE(l->contains("hw-address"));
EXPECT_FALSE(l->contains("user-context"));
+ ASSERT_TRUE(l->contains("pool-id"));
+ EXPECT_EQ(5, l->get("pool-id")->intValue());
+
// And to finish try with a comment.
lease.setContext(Element::fromJSON("{ \"comment\": \"a comment\" }"));
+
l = lease.toElement();
EXPECT_FALSE(l->contains("hw-address"));
ConstElementPtr ctx = l->get("user-context");
@@ -1153,6 +1159,9 @@ TEST(Lease6Test, toElementPrefix) {
EXPECT_EQ(1, ctx->size());
ASSERT_TRUE(ctx->contains("comment"));
EXPECT_EQ("a comment", ctx->get("comment")->stringValue());
+
+ ASSERT_TRUE(l->contains("pool-id"));
+ EXPECT_EQ(5, l->get("pool-id")->intValue());
}
// Verify that the IA_NA can be created from JSON.
@@ -1302,6 +1311,7 @@ TEST(Lease6Test, fromElementInvalidValues) {
testInvalidElement<Lease6>(json, "subnet-id", 0x100000000, false);
testInvalidElement<Lease6>(json, "pool-id", std::string("xyz"), false);
testInvalidElement<Lease6>(json, "pool-id", -5, false);
+ testInvalidElement<Lease6>(json, "pool-id", 0, false);
testInvalidElement<Lease6>(json, "pool-id", 0x100000000, false);
testInvalidElement<Lease6>(json, "type", std::string("IA_XY"));
testInvalidElement<Lease6>(json, "type", -3, false);
diff --git a/src/lib/dhcpsrv/testutils/test_utils.cc b/src/lib/dhcpsrv/testutils/test_utils.cc
index 4fe7d86d93..14edc7dd9b 100644
--- a/src/lib/dhcpsrv/testutils/test_utils.cc
+++ b/src/lib/dhcpsrv/testutils/test_utils.cc
@@ -53,6 +53,7 @@ detailCompareLease(const Lease4Ptr& first, const Lease4Ptr& second) {
EXPECT_EQ(first->valid_lft_, second->valid_lft_);
EXPECT_EQ(first->cltt_, second->cltt_);
EXPECT_EQ(first->subnet_id_, second->subnet_id_);
+ EXPECT_EQ(first->pool_id_, second->pool_id_);
EXPECT_EQ(first->fqdn_fwd_, second->fqdn_fwd_);
EXPECT_EQ(first->fqdn_rev_, second->fqdn_rev_);
EXPECT_EQ(first->hostname_, second->hostname_);
@@ -86,6 +87,7 @@ detailCompareLease(const Lease6Ptr& first, const Lease6Ptr& second) {
EXPECT_EQ(first->valid_lft_, second->valid_lft_);
EXPECT_EQ(first->cltt_, second->cltt_);
EXPECT_EQ(first->subnet_id_, second->subnet_id_);
+ EXPECT_EQ(first->pool_id_, second->pool_id_);
EXPECT_EQ(first->fqdn_fwd_, second->fqdn_fwd_);
EXPECT_EQ(first->fqdn_rev_, second->fqdn_rev_);
EXPECT_EQ(first->hostname_, second->hostname_);