|
@@ -562,6 +562,7 @@ TEST_F(Dhcp6ParserTest, subnetGlobalDefaults) {
|
|
|
EXPECT_EQ(1, subnet->getID());
|
|
|
}
|
|
|
|
|
|
+// This test checks that multiple subnets can be defined and handled properly.
|
|
|
TEST_F(Dhcp6ParserTest, multipleSubnets) {
|
|
|
ConstElementPtr x;
|
|
|
// Collection of four subnets for which ids should be autogenerated
|
|
@@ -1046,6 +1047,62 @@ TEST_F(Dhcp6ParserTest, subnetInterfaceAndInterfaceId) {
|
|
|
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
|
|
|
}
|
|
|
|
|
|
+// This test checks that multiple pools can be defined and handled properly.
|
|
|
+// The test defines 2 subnets, each with 2 pools.
|
|
|
+TEST_F(Dhcp6ParserTest, multiplePools) {
|
|
|
+ // Collection with two subnets, each with 2 pools.
|
|
|
+ string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
+ "\"preferred-lifetime\": 3000,"
|
|
|
+ "\"rebind-timer\": 2000, "
|
|
|
+ "\"renew-timer\": 1000, "
|
|
|
+ "\"subnet6\": [ { "
|
|
|
+ " \"pools\": [ "
|
|
|
+ " { \"pool\": \"2001:db8:1::/96\" },"
|
|
|
+ " { \"pool\": \"2001:db8:1:0:abcd::/112\" }"
|
|
|
+ " ],"
|
|
|
+ " \"subnet\": \"2001:db8:1::/64\" "
|
|
|
+ " },"
|
|
|
+ " {"
|
|
|
+ " \"pools\": [ "
|
|
|
+ " { \"pool\": \"2001:db8:2::1 - 2001:db8:2::ff\" },"
|
|
|
+ " { \"pool\": \"2001:db8:2::300 - 2001:db8:2::3ff\" }"
|
|
|
+ " ],"
|
|
|
+ " \"subnet\": \"2001:db8:2::/64\""
|
|
|
+ " } ],"
|
|
|
+ "\"valid-lifetime\": 4000 }";
|
|
|
+ ElementPtr json;
|
|
|
+ ASSERT_NO_THROW(json = Element::fromJSON(config));
|
|
|
+
|
|
|
+ ConstElementPtr status;
|
|
|
+ ASSERT_NO_THROW(status = configureDhcp6Server(srv_, json));
|
|
|
+ checkResult(status, 0);
|
|
|
+
|
|
|
+ const Subnet6Collection* subnets = CfgMgr::instance().getSubnets6();
|
|
|
+ ASSERT_TRUE(subnets);
|
|
|
+ ASSERT_EQ(2, subnets->size()); // We expect 2 subnets
|
|
|
+
|
|
|
+ // Check the first subnet
|
|
|
+ const PoolCollection& pools1 = subnets->at(0)->getPools(Lease::TYPE_NA);
|
|
|
+ ASSERT_EQ(2, pools1.size());
|
|
|
+ EXPECT_EQ("type=IA_NA, 2001:db8:1::-2001:db8:1::ffff:ffff, delegated_len=128",
|
|
|
+ pools1[0]->toText());
|
|
|
+ EXPECT_EQ("type=IA_NA, 2001:db8:1:0:abcd::-2001:db8:1:0:abcd::ffff, delegated_len=128",
|
|
|
+ pools1[1]->toText());
|
|
|
+ // There shouldn't be any TA or PD pools
|
|
|
+ EXPECT_TRUE(subnets->at(0)->getPools(Lease::TYPE_TA).empty());
|
|
|
+ EXPECT_TRUE(subnets->at(0)->getPools(Lease::TYPE_PD).empty());
|
|
|
+
|
|
|
+ // Check the second subnet
|
|
|
+ const PoolCollection& pools2 = subnets->at(1)->getPools(Lease::TYPE_NA);
|
|
|
+ ASSERT_EQ(2, pools2.size());
|
|
|
+ EXPECT_EQ("type=IA_NA, 2001:db8:2::1-2001:db8:2::ff, delegated_len=128",
|
|
|
+ pools2[0]->toText());
|
|
|
+ EXPECT_EQ("type=IA_NA, 2001:db8:2::300-2001:db8:2::3ff, delegated_len=128",
|
|
|
+ pools2[1]->toText());
|
|
|
+ // There shouldn't be any TA or PD pools
|
|
|
+ EXPECT_TRUE(subnets->at(0)->getPools(Lease::TYPE_TA).empty());
|
|
|
+ EXPECT_TRUE(subnets->at(0)->getPools(Lease::TYPE_PD).empty());
|
|
|
+}
|
|
|
|
|
|
|
|
|
// Test verifies that a subnet with pool values that do not belong to that
|