]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3150] Extra unit-test for temp. address pool
authorTomek Mrugalski <tomasz@isc.org>
Mon, 16 Sep 2013 12:44:31 +0000 (14:44 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Mon, 16 Sep 2013 12:44:31 +0000 (14:44 +0200)
src/lib/dhcpsrv/pool.cc
src/lib/dhcpsrv/tests/pool_unittest.cc

index e9d057fd7c02ac2270406056db6a240972374c62..ee5e64ea88fdd2cb5594f97184a381c40d272a72 100644 (file)
@@ -63,7 +63,7 @@ Pool4::Pool4( const isc::asiolink::IOAddress& prefix, uint8_t prefix_len)
 
 Pool6::Pool6(PoolType type, const isc::asiolink::IOAddress& first,
              const isc::asiolink::IOAddress& last)
-    :Pool(type, first, last) {
+    :Pool(type, first, last), prefix_len_(128) {
 
     // check if specified address boundaries are sane
     if (!first.isV6() || !last.isV6()) {
index d0cbf66896e7fac1993cbbc3e77f250c97e0def0..e7d85407ff6f87d9add6feaab1984f5fd466476f 100644 (file)
@@ -190,6 +190,38 @@ TEST(Pool6Test, PD) {
                                 77, 77));
 }
 
+// Checks that temporary address pools are handled properly
+TEST(Pool6Test, TA) {
+    // Note: since we defined TA pool types during PD work, we can test it
+    // now. Although the configuration to take advantage of it is not
+    // planned for now, we will support it some day.
+
+    // Let's construct 2001:db8:1::/96 temporary addresses
+    Pool6Ptr pool1;
+    EXPECT_NO_THROW(pool1.reset(new Pool6(Pool6::TYPE_TA,
+                                          IOAddress("2001:db8:1::"), 96)));
+
+    // Check that TA range can be only defined for single addresses
+    EXPECT_THROW(Pool6(Pool6::TYPE_TA, IOAddress("2001:db8:1::"), 96, 127),
+                 BadValue);
+
+    ASSERT_TRUE(pool1);
+    EXPECT_EQ(Pool6::TYPE_TA, pool1->getType());
+    EXPECT_EQ(128, pool1->getLength()); // singular addresses, not prefixes
+    EXPECT_EQ("2001:db8:1::", pool1->getFirstAddress().toText());
+    EXPECT_EQ("2001:db8:1::ffff:ffff", pool1->getLastAddress().toText());
+
+    // Check that it's possible to have min-max range for TA
+    Pool6Ptr pool2;
+    EXPECT_NO_THROW(pool2.reset(new Pool6(Pool6::TYPE_TA,
+                                          IOAddress("2001:db8:1::1"),
+                                          IOAddress("2001:db8:1::f"))));
+    ASSERT_TRUE(pool2);
+    EXPECT_EQ(Pool6::TYPE_TA, pool2->getType());
+    EXPECT_EQ(128, pool2->getLength()); // singular addresses, not prefixes
+    EXPECT_EQ("2001:db8:1::1", pool2->getFirstAddress().toText());
+    EXPECT_EQ("2001:db8:1::f", pool2->getLastAddress().toText());
+}
 
 // This test creates 100 pools and verifies that their IDs are unique.
 TEST(Pool6Test, unique_id) {