From: Marcin Siodelski Date: Fri, 17 Jun 2016 14:34:35 +0000 (+0200) Subject: [4321] Added unit test for Solicit after lease acquisition. X-Git-Tag: trac4551_base~29^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd397470f4092036f173be01ea48cd3a1a48c797;p=thirdparty%2Fkea.git [4321] Added unit test for Solicit after lease acquisition. The new test uses swapped addresses as hints after acquiring these addresses in a 4-way exchange. The server ignores hints. --- diff --git a/src/bin/dhcp6/tests/host_unittest.cc b/src/bin/dhcp6/tests/host_unittest.cc index 06b29e8d0e..e406b971d3 100644 --- a/src/bin/dhcp6/tests/host_unittest.cc +++ b/src/bin/dhcp6/tests/host_unittest.cc @@ -58,7 +58,7 @@ const char* CONFIGS[] = { " \"ip-addresses\": [ \"2001:db8:1:1::babf\" ]" " } ]" " } ]" - "}", + "}", // Configuration 1: "{ " @@ -1028,6 +1028,57 @@ TEST_F(HostTest, multipleIAsRenew) { EXPECT_TRUE(client_.hasLeaseForPrefix(IOAddress("3000:1:3::"), 64)); } +// In this test, the client performs 4-way exchange and includes 3 IA_NAs +// and IA_PDs. The server has 3 address and 3 prefix reservations for the +// client and allocates them all. Once the 4-way exchange is complete, +// the client sends Solicit in which it specifies hints for all IAs. The +// hints are for the reserved addresses but some of them are included in +// different IAs than they are assigned to. The server should ignore hints +// and respond with currently assigned leases. +TEST_F(HostTest, multipleIAsSolicitAfterAcquisition) { + // 4-way exchange + testMultipleIAs(do_solicit_request_, + Reservation("2001:db8:1:1::1"), + Reservation("2001:db8:1:1::2"), + Reservation("2001:db8:1:1::3"), + Reservation("3000:1:1::/64"), + Reservation("3000:1:2::/64"), + Reservation("3000:1:3::/64")); + + client_.clearRequestedIAs(); + + // Specify hints. + + // "2001:db8:1:1::1" is allocated for IAID = 1 but we specify it as + // a hint for IAID = 3 and so on. + requestIA(client_, Hint(IAID(3), "2001:db8:1:1::1")); + requestIA(client_, Hint(IAID(2), "2001:db8:1:1::2")); + requestIA(client_, Hint(IAID(1), "2001:db8:1:1::3")); + requestIA(client_, Hint(IAID(6), "3000:1:1::/64")); + requestIA(client_, Hint(IAID(5), "3000:1:2::/64")); + requestIA(client_, Hint(IAID(4), "3000:1:3::/64")); + + // Send Solicit with hints as specified above. + ASSERT_NO_THROW(do_solicit_()); + + // Make sure that the client still has the same leases and the leases + // should be assigned to the same IAs. + ASSERT_EQ(6, client_.getLeaseNum()); + + EXPECT_TRUE(client_.hasLeaseForAddress(IOAddress("2001:db8:1:1::1"), + IAID(1))); + EXPECT_TRUE(client_.hasLeaseForAddress(IOAddress("2001:db8:1:1::2"), + IAID(2))); + EXPECT_TRUE(client_.hasLeaseForAddress(IOAddress("2001:db8:1:1::3"), + IAID(3))); + EXPECT_TRUE(client_.hasLeaseForPrefix(IOAddress("3000:1:1::"), 64, + IAID(4))); + EXPECT_TRUE(client_.hasLeaseForPrefix(IOAddress("3000:1:2::"), 64, + IAID(5))); + EXPECT_TRUE(client_.hasLeaseForPrefix(IOAddress("3000:1:3::"), 64, + IAID(6))); +} + // In this test, the client performs 4-way exchange and includes 3 IA_NAs and // 3 IA_PDs and includes no hints. The server has reservations for 2 addresses // and 2 prefixes for this client. The server allocates reserved leases and