]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2615] Corrected NO_HR index and text
authorThomas Markwalder <tmark@isc.org>
Tue, 25 Aug 2015 18:58:56 +0000 (14:58 -0400)
committerThomas Markwalder <tmark@isc.org>
Tue, 25 Aug 2015 18:58:56 +0000 (14:58 -0400)
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.

src/bin/dhcp4/tests/out_of_range_unittest.cc
src/bin/dhcp6/tests/Makefile.am
src/bin/dhcp6/tests/dhcp6_client.cc
src/bin/dhcp6/tests/dhcp6_client.h

index f3ef2576d6ee22d7b99d0e54ec5f3ba3260ac2b7..066cf45810134721f840e05797a5d4eb772441a0 100644 (file)
@@ -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<int>(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,
index f00c7520dd7c19a32a8f6712baf359284bd1cf2b..ae23ffee9aaee95de8f6a9cb717e8fa850572397 100644 (file)
@@ -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
 
index 9de4755c8b034cf659fe713baef18f524e62f54c..18f21aa53dc5e8e765f61b015f950a1daf060cf2 100644 (file)
@@ -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);
index 35462321ce5a00f48aef9d20d77420ce6cdfde68..e1cf0a5ca062f1925a4ecffcd04049bb66898c05 100644 (file)
@@ -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