|
@@ -1102,6 +1102,77 @@ TEST_F(Dhcp4ParserTest, echoClientId) {
|
|
|
CfgMgr::instance().echoClientId(true);
|
|
|
}
|
|
|
|
|
|
+// This test checks that the global ignore-client-id parameter is optional
|
|
|
+// and that values under the subnet are used.
|
|
|
+TEST_F(Dhcp4ParserTest, ignoreClientIdNoGlobal) {
|
|
|
+ ConstElementPtr status;
|
|
|
+
|
|
|
+ std::string config = "{ " + genIfaceConfig() + "," +
|
|
|
+ "\"rebind-timer\": 2000, "
|
|
|
+ "\"renew-timer\": 1000, "
|
|
|
+ "\"subnet4\": [ "
|
|
|
+ "{"
|
|
|
+ " \"ignore-client-id\": true,"
|
|
|
+ " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
|
|
|
+ " \"subnet\": \"192.0.2.0/24\""
|
|
|
+ "},"
|
|
|
+ "{"
|
|
|
+ " \"ignore-client-id\": false,"
|
|
|
+ " \"pools\": [ { \"pool\": \"192.0.3.1 - 192.0.3.100\" } ],"
|
|
|
+ " \"subnet\": \"192.0.3.0/24\""
|
|
|
+ "} ],"
|
|
|
+ "\"valid-lifetime\": 4000 }";
|
|
|
+
|
|
|
+ ElementPtr json = Element::fromJSON(config);
|
|
|
+ ASSERT_NO_THROW(status = configureDhcp4Server(*srv_, json));
|
|
|
+ checkResult(status, 0);
|
|
|
+
|
|
|
+ CfgSubnets4Ptr cfg = CfgMgr::instance().getStagingCfg()->getCfgSubnets4();
|
|
|
+ Subnet4Ptr subnet1 = cfg->selectSubnet(IOAddress("192.0.2.1"));
|
|
|
+ ASSERT_TRUE(subnet1);
|
|
|
+ EXPECT_TRUE(subnet1->getIgnoreClientId());
|
|
|
+
|
|
|
+ Subnet4Ptr subnet2 = cfg->selectSubnet(IOAddress("192.0.3.1"));
|
|
|
+ ASSERT_TRUE(subnet2);
|
|
|
+ EXPECT_FALSE(subnet2->getIgnoreClientId());
|
|
|
+}
|
|
|
+
|
|
|
+// This test checks that the global ignore-client-id parameter is used
|
|
|
+// when there is no such parameter under subnet and that the parameter
|
|
|
+// specified for a subnet overrides the global setting.
|
|
|
+TEST_F(Dhcp4ParserTest, ignoreClientIdGlobal) {
|
|
|
+ ConstElementPtr status;
|
|
|
+
|
|
|
+ std::string config = "{ " + genIfaceConfig() + "," +
|
|
|
+ "\"rebind-timer\": 2000, "
|
|
|
+ "\"renew-timer\": 1000, "
|
|
|
+ "\"ignore-client-id\": true,"
|
|
|
+ "\"subnet4\": [ "
|
|
|
+ "{"
|
|
|
+ " \"ignore-client-id\": false,"
|
|
|
+ " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
|
|
|
+ " \"subnet\": \"192.0.2.0/24\""
|
|
|
+ "},"
|
|
|
+ "{"
|
|
|
+ " \"pools\": [ { \"pool\": \"192.0.3.1 - 192.0.3.100\" } ],"
|
|
|
+ " \"subnet\": \"192.0.3.0/24\""
|
|
|
+ "} ],"
|
|
|
+ "\"valid-lifetime\": 4000 }";
|
|
|
+
|
|
|
+ ElementPtr json = Element::fromJSON(config);
|
|
|
+ ASSERT_NO_THROW(status = configureDhcp4Server(*srv_, json));
|
|
|
+ checkResult(status, 0);
|
|
|
+
|
|
|
+ CfgSubnets4Ptr cfg = CfgMgr::instance().getStagingCfg()->getCfgSubnets4();
|
|
|
+ Subnet4Ptr subnet1 = cfg->selectSubnet(IOAddress("192.0.2.1"));
|
|
|
+ ASSERT_TRUE(subnet1);
|
|
|
+ EXPECT_FALSE(subnet1->getIgnoreClientId());
|
|
|
+
|
|
|
+ Subnet4Ptr subnet2 = cfg->selectSubnet(IOAddress("192.0.3.1"));
|
|
|
+ ASSERT_TRUE(subnet2);
|
|
|
+ EXPECT_TRUE(subnet2->getIgnoreClientId());
|
|
|
+}
|
|
|
+
|
|
|
// This test checks if it is possible to override global values
|
|
|
// on a per subnet basis.
|
|
|
TEST_F(Dhcp4ParserTest, subnetLocal) {
|