]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3677] Two unit-tests fixed.
authorTomek Mrugalski <tomasz@isc.org>
Fri, 6 Feb 2015 17:44:39 +0000 (18:44 +0100)
committerTomek Mrugalski <tomasz@isc.org>
Fri, 6 Feb 2015 17:44:39 +0000 (18:44 +0100)
src/bin/dhcp6/tests/dhcp6_client.cc
src/bin/dhcp6/tests/dhcp6_client.h
src/bin/dhcp6/tests/rebind_unittest.cc

index 01dfc57c7387bb8d4ac662fa2712136ab0e24512..73720695a9405cc90da0b9bd9ae84d8d98103fcb 100644 (file)
@@ -88,7 +88,8 @@ Dhcp6Client::applyRcvdConfiguration(const Pkt6Ptr& reply) {
             case D6O_IAADDR:
                 {
                     Option6IAAddrPtr iaaddr = boost::dynamic_pointer_cast<
-                        Option6IAAddr>(ia->getOption(D6O_IAADDR));
+                        Option6IAAddr>(ia_opt);
+
                     if (!iaaddr) {
                         // There is no address. This IA option may simply
                         // contain a status code, so let's just reset the
@@ -113,7 +114,7 @@ Dhcp6Client::applyRcvdConfiguration(const Pkt6Ptr& reply) {
             case D6O_IAPREFIX:
                 {
                     Option6IAPrefixPtr iaprefix = boost::dynamic_pointer_cast<
-                        Option6IAPrefix>(ia->getOption(D6O_IAPREFIX));
+                        Option6IAPrefix>(ia_opt);
                     if (!iaprefix) {
                         // There is no prefix. This IA option may simply
                         // contain a status code, so let's just reset the
index 8332df50cac70662d2c222286d5e335b4da40a2d..6bade76fdb8f462fdef7a8c9e1f412bf4892f529 100644 (file)
@@ -406,6 +406,12 @@ public:
         oro_.push_back(option_code);
     }
 
+    /// @brief returns client-id
+    /// @return client-id
+    DuidPtr getDuid() {
+        return (duid_);
+    }
+
 private:
 
     /// @brief Applies the new leases for the client.
index 3a7df87579a6e770c438ec34640af4e9e5bea1df..09a24bd7a81b6287b0fe2c1a606f6c40d809b596 100644 (file)
@@ -474,13 +474,31 @@ TEST_F(RebindTest, relayedClientChangingAddress) {
         << "The server discarded the Rebind message, while it should have"
         " sent a response indicating that the client should stop using the"
         " lease, by setting lifetime values to 0.";
-    // Get the client's lease.
-    ASSERT_EQ(1, client.getLeaseNum());
-    Lease6 lease_client2 = client.getLease(0);
+    // Get the client's leases. He should get two addresses:
+    // the first one for the bogus 3000::100 address with 0 lifetimes.
+    // the second one with the actual lease with non-zero lifetimes.
+    ASSERT_EQ(2, client.getLeaseNum());
+
+    // Let's check the first one
+    Lease6 lease_client1 = client.getLease(0);
+    Lease6 lease_client2 = client.getLease(1);
+
+    if (lease_client1.addr_.toText() != "3000::100") {
+        lease_client1 = client.getLease(1);
+        lease_client2 = client.getLease(0);
+    }
+
     // The lifetimes should be set to 0, as an explicit notification to the
     // client to stop using invalid prefix.
-    EXPECT_EQ(0, lease_client2.valid_lft_);
-    EXPECT_EQ(0, lease_client2.preferred_lft_);
+    EXPECT_EQ(0, lease_client1.valid_lft_);
+    EXPECT_EQ(0, lease_client1.preferred_lft_);
+
+    // Let's check the second lease
+    // The lifetimes should be set to 0, as an explicit notification to the
+    // client to stop using invalid prefix.
+    EXPECT_NE(0, lease_client2.valid_lft_);
+    EXPECT_NE(0, lease_client2.preferred_lft_);
+
     // Check that server still has the same lease.
     Lease6Ptr lease_server = checkLease(lease_client);
     EXPECT_TRUE(lease_server);
@@ -610,12 +628,24 @@ TEST_F(RebindTest, directClientPDChangingPrefix) {
         " sent a response indicating that the client should stop using the"
         " lease, by setting lifetime values to 0.";
     // Get the client's lease.
-    ASSERT_EQ(1, client.getLeaseNum());
-    Lease6 lease_client2 = client.getLease(0);
+    ASSERT_EQ(2, client.getLeaseNum());
+
+    // Client should get two entries. One with the invalid address he requested
+    // with zeroed lifetimes and a second one with the actual prefix he has
+    // with non-zero lifetimes.
+    Lease6 lease_client1 = client.getLease(0);
+    Lease6 lease_client2 = client.getLease(1);
+
     // The lifetimes should be set to 0, as an explicit notification to the
     // client to stop using invalid prefix.
-    EXPECT_EQ(0, lease_client2.valid_lft_);
-    EXPECT_EQ(0, lease_client2.preferred_lft_);
+    EXPECT_EQ(0, lease_client1.valid_lft_);
+    EXPECT_EQ(0, lease_client1.preferred_lft_);
+
+    // The lifetimes should be set to 0, as an explicit notification to the
+    // client to stop using invalid prefix.
+    EXPECT_NE(0, lease_client2.valid_lft_);
+    EXPECT_NE(0, lease_client2.preferred_lft_);
+
     // Check that server still has the same lease.
     Lease6Ptr lease_server = checkLease(lease_client);
     ASSERT_TRUE(lease_server);