From: Thomas Markwalder Date: Tue, 25 Aug 2015 18:58:56 +0000 (-0400) Subject: [2615] Corrected NO_HR index and text X-Git-Tag: fd4o6_base~8^2~2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=55207601c7a71e7db55d8fff2b451b054a7b315e;p=thirdparty%2Fkea.git [2615] Corrected NO_HR index and text The NO_HR enum value was erroneously set to an explicit value, causing the wrong text to be used for some tests. Changed reserved host name in config to avoid causing NCR remove/adds during renewals. --- diff --git a/src/bin/dhcp4/tests/out_of_range_unittest.cc b/src/bin/dhcp4/tests/out_of_range_unittest.cc index f3ef2576d6..066cf45810 100644 --- a/src/bin/dhcp4/tests/out_of_range_unittest.cc +++ b/src/bin/dhcp4/tests/out_of_range_unittest.cc @@ -70,7 +70,7 @@ const char* OOR_CONFIGS[] = { " }," " {" " \"hw-address\": \"dd:dd:dd:dd:dd:01\"," - " \"hostname\": \"reserved.example.com\"" + " \"hostname\": \"test.example.com\"" " }" " ]" "} ]," @@ -168,7 +168,7 @@ const char* OOR_CONFIGS[] = { "\"valid-lifetime\": 600," "\"subnet4\": [ { " " \"subnet\": \"10.0.0.0/24\", " - " \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ]," + " \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ]" "} ]," "\"dhcp-ddns\": {" " \"enable-updates\": true," @@ -186,7 +186,7 @@ enum CfgIndex { DIFF_POOL_NO_HR, DIFF_SUBNET, DIFF_SUBNET_NO_HR, - NO_HR = 4 + NO_HR }; /// @brief Enum for specifying expected response to client renewal attempt @@ -242,7 +242,7 @@ public: /// @param addr - string containing the ip address expected in the NCR void verifyNameChangeRequest(const isc::dhcp_ddns::NameChangeType type, const std::string& addr) { - ASSERT_EQ(1, d2_mgr_.getQueueSize()); + ASSERT_TRUE(d2_mgr_.getQueueSize() > 0); isc::dhcp_ddns::NameChangeRequestPtr ncr; ASSERT_NO_THROW(ncr = d2_mgr_.peekAt(0)); @@ -253,7 +253,6 @@ public: // Process the message off the queue ASSERT_NO_THROW(d2_mgr_.runReadyIO()); - ASSERT_EQ(0, d2_mgr_.getQueueSize()); } /// @brief Conducts a single out-of-range test scenario @@ -348,6 +347,7 @@ OutOfRangeTest::oorRenewReleaseTest(enum CfgIndex cfg_idx, // Verify that we received an ACK to our renewal resp = client.getContext().response_; ASSERT_EQ(DHCPACK, static_cast(resp->getType())); + EXPECT_EQ(0, d2_mgr_.getQueueSize()); // STAGE TWO: @@ -448,10 +448,10 @@ TEST_F(OutOfRangeTest, dynamicHostOutOfSubnet) { } // Test verifies that once-valid dynamic address host reserveration, -// whose address is within the configured subnet, but whose +// whose address is within the configured subnet and pool, but whose // reservation has been removed: // -// a: Is NAKed upon a renewal attempt +// a: Is allowed to renew // b: Is released properly upon release, including DNS removal // TEST_F(OutOfRangeTest, dynamicHostReservationRemoved) { @@ -460,7 +460,7 @@ TEST_F(OutOfRangeTest, dynamicHostReservationRemoved) { std::string hwaddress = "dd:dd:dd:dd:dd:01"; std::string expected_address = ""; - oorRenewReleaseTest(NO_HR, hwaddress, expected_address, DOES_NOT_RENEW); + oorRenewReleaseTest(NO_HR, hwaddress, expected_address, DOES_RENEW); } // Test verifies that once-valid dynamic address host reserveration, diff --git a/src/bin/dhcp6/tests/Makefile.am b/src/bin/dhcp6/tests/Makefile.am index f00c7520dd..ae23ffee9a 100644 --- a/src/bin/dhcp6/tests/Makefile.am +++ b/src/bin/dhcp6/tests/Makefile.am @@ -88,6 +88,7 @@ dhcp6_unittests_SOURCES += config_parser_unittest.cc dhcp6_unittests_SOURCES += confirm_unittest.cc dhcp6_unittests_SOURCES += infrequest_unittest.cc dhcp6_unittests_SOURCES += dhcp6_message_test.cc dhcp6_message_test.h +dhcp6_unittests_SOURCES += out_of_range_unittest.cc dhcp6_unittests_SOURCES += kea_controller_unittest.cc diff --git a/src/bin/dhcp6/tests/dhcp6_client.cc b/src/bin/dhcp6/tests/dhcp6_client.cc index 9de4755c8b..18f21aa53d 100644 --- a/src/bin/dhcp6/tests/dhcp6_client.cc +++ b/src/bin/dhcp6/tests/dhcp6_client.cc @@ -336,11 +336,11 @@ Dhcp6Client::doRequest() { query->addOption(forced_server_id_); } copyIAs(context_.response_, query); + context_.query_ = query; // Add Client FQDN if configured. appendFQDN(); - context_.query_ = query; sendMsg(context_.query_); context_.response_ = receiveOneMsg(); @@ -383,11 +383,11 @@ Dhcp6Client::doRenew() { Pkt6Ptr query = createMsg(DHCPV6_RENEW); query->addOption(context_.response_->getOption(D6O_SERVERID)); copyIAsFromLeases(query); + context_.query_ = query; // Add Client FQDN if configured. appendFQDN(); - context_.query_ = query; sendMsg(context_.query_); context_.response_ = receiveOneMsg(); // Apply configuration only if the server has responded. @@ -400,6 +400,29 @@ void Dhcp6Client::doRebind() { Pkt6Ptr query = createMsg(DHCPV6_REBIND); copyIAsFromLeases(query); + context_.query_ = query; + + // Add Client FQDN if configured. + appendFQDN(); + + sendMsg(context_.query_); + context_.response_ = receiveOneMsg(); + // Apply configuration only if the server has responded. + if (context_.response_) { + applyRcvdConfiguration(context_.response_); + } +} + + +void +Dhcp6Client::doRelease() { + Pkt6Ptr query = createMsg(DHCPV6_RELEASE); + if (!forced_server_id_) { + query->addOption(context_.response_->getOption(D6O_SERVERID)); + } else { + query->addOption(forced_server_id_); + } + copyIAsFromLeases(query); // Add Client FQDN if configured. appendFQDN(); @@ -413,6 +436,7 @@ Dhcp6Client::doRebind() { } } + void Dhcp6Client::doConfirm() { context_.query_ = createMsg(DHCPV6_CONFIRM); diff --git a/src/bin/dhcp6/tests/dhcp6_client.h b/src/bin/dhcp6/tests/dhcp6_client.h index 35462321ce..e1cf0a5ca0 100644 --- a/src/bin/dhcp6/tests/dhcp6_client.h +++ b/src/bin/dhcp6/tests/dhcp6_client.h @@ -235,6 +235,8 @@ public: /// @todo Perform sanity checks on returned messages. void doRebind(); + void doRelease(); + /// @brief Sends Request to the server and receives Reply. /// /// This function simulates sending the Request message to the server and