EXPECT_NO_THROW(status = configureDhcp4Server(*srv_, json));
string expected = "subnet configuration failed: "
"the value of min-valid-lifetime (2000) is not "
- "less than max-valid-lifetime (1000)";
+ "less than (default) valid-lifetime (1000)";
checkResult(status, 1, expected);
resetConfiguration();
ASSERT_NO_THROW(json = parseDHCP4(too_large));
EXPECT_NO_THROW(status = configureDhcp4Server(*srv_, json));
+ expected = "subnet configuration failed: "
+ "the value of (default) valid-lifetime (2000) is not "
+ "less than max-valid-lifetime (1000)";
checkResult(status, 1, expected);
resetConfiguration();
"the value of (default) valid-lifetime (5000) is not "
"between min-valid-lifetime (1000) and max-valid-lifetime (4000)";
checkResult(status, 1, expected);
+ resetConfiguration();
+
+ string crossed = "{ " + genIfaceConfig() + "," +
+ "\"subnet4\": [ { "
+ " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
+ " \"subnet\": \"192.0.2.0/24\" } ],"
+ "\"valid-lifetime\": 1500, \"min-valid-lifetime\": 2000, "
+ "\"max-valid-lifetime\": 1000 }";
+
+ ASSERT_NO_THROW(json = parseDHCP4(crossed));
+ EXPECT_NO_THROW(status = configureDhcp4Server(*srv_, json));
+ expected = "subnet configuration failed: "
+ "the value of min-valid-lifetime (2000) is not "
+ "less than max-valid-lifetime (1000)";
+ checkResult(status, 1, expected);
}
/// Check that the renew-timer doesn't have to be specified, in which case
EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
string expected = "subnet configuration failed: "
"the value of min-valid-lifetime (2000) is not "
- "less than max-valid-lifetime (1000)";
+ "less than (default) valid-lifetime (1000)";
checkResult(status, 1, expected);
resetConfiguration();
ASSERT_NO_THROW(json = parseDHCP6(too_large));
EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
+ expected = "subnet configuration failed: "
+ "the value of (default) valid-lifetime (2000) is not "
+ "less than max-valid-lifetime (1000)";
checkResult(status, 1, expected);
resetConfiguration();
"the value of (default) valid-lifetime (5000) is not "
"between min-valid-lifetime (1000) and max-valid-lifetime (4000)";
checkResult(status, 1, expected);
+ resetConfiguration();
+
+ string crossed = "{ " + genIfaceConfig() + "," +
+ "\"subnet6\": [ { "
+ " \"pools\": [ { \"pool\": \"2001:db8::/64\" } ],"
+ " \"subnet\": \"2001:db8::/32\" } ],"
+ "\"valid-lifetime\": 1500, \"min-valid-lifetime\": 2000, "
+ "\"max-valid-lifetime\": 1000 }";
+ ASSERT_NO_THROW(json = parseDHCP6(crossed));
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
+ expected = "subnet configuration failed: "
+ "the value of min-valid-lifetime (2000) is not "
+ "less than max-valid-lifetime (1000)";
+ checkResult(status, 1, expected);
}
/// Check that preferred-lifetime must be between min-preferred-lifetime and
EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
string expected = "subnet configuration failed: "
"the value of min-preferred-lifetime (2000) is not "
- "less than max-preferred-lifetime (1000)";
+ "less than (default) preferred-lifetime (1000)";
checkResult(status, 1, expected);
resetConfiguration();
ASSERT_NO_THROW(json = parseDHCP6(too_large));
EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
+ expected = "subnet configuration failed: "
+ "the value of (default) preferred-lifetime (2000) is not "
+ "less than max-preferred-lifetime (1000)";
checkResult(status, 1, expected);
resetConfiguration();
"the value of (default) preferred-lifetime (5000) is not between "
"min-preferred-lifetime (1000) and max-preferred-lifetime (4000)";
checkResult(status, 1, expected);
+ resetConfiguration();
+
+ string crossed = "{ " + genIfaceConfig() + "," +
+ "\"subnet6\": [ { "
+ " \"pools\": [ { \"pool\": \"2001:db8::/64\" } ],"
+ " \"subnet\": \"2001:db8::/32\" } ],"
+ "\"preferred-lifetime\": 1500, \"min-preferred-lifetime\": 2000, "
+ "\"max-preferred-lifetime\": 1000 }";
+ ASSERT_NO_THROW(json = parseDHCP6(crossed));
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
+ expected = "subnet configuration failed: "
+ "the value of min-preferred-lifetime (2000) is not "
+ "less than max-preferred-lifetime (1000)";
+ checkResult(status, 1, expected);
}
/// The goal of this test is to verify if configuration without any
}
// Check that min <= max.
if (min_value > max_value) {
- isc_throw(DhcpConfigError, "the value of min-" << name << " ("
- << min_value << ") is not less than max-" << name << " ("
- << max_value << ")");
+ if (has_min && has_max) {
+ isc_throw(DhcpConfigError, "the value of min-" << name << " ("
+ << min_value << ") is not less than max-" << name << " ("
+ << max_value << ")");
+ } else if (has_min) {
+ // Only min and default so min > default.
+ isc_throw(DhcpConfigError, "the value of min-" << name << " ("
+ << min_value << ") is not less than (default) " << name
+ << " (" << value << ")");
+ } else {
+ // Only default and max so default > max.
+ isc_throw(DhcpConfigError, "the value of (default) " << name
+ << " (" << value << ") is not less than max-" << name
+ << " (" << max_value << ")");
+ }
}
// Check that value is between min and max.
if ((value < min_value) || (value > max_value)) {