mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 14:05:33 +00:00
[#1456] Addressed comments
This commit is contained in:
@@ -1102,6 +1102,7 @@ TEST_F(Dhcp6ParserTest, outBoundValidLifetime) {
|
||||
" \"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: "
|
||||
@@ -1113,7 +1114,7 @@ TEST_F(Dhcp6ParserTest, outBoundValidLifetime) {
|
||||
/// Check that valid-lifetime must be between min-valid-lifetime and
|
||||
/// max-valid-lifetime when a bound is specified. Check on global
|
||||
/// parameters only.
|
||||
TEST_F(Dhcp6ParserTest, outGlobalBoundValidLifetime) {
|
||||
TEST_F(Dhcp6ParserTest, outBoundGlobaValidLifetime) {
|
||||
|
||||
string too_small = "{ " + genIfaceConfig() + "," +
|
||||
"\"valid-lifetime\": 1000, \"min-valid-lifetime\": 2000 }";
|
||||
@@ -1167,6 +1168,7 @@ TEST_F(Dhcp6ParserTest, outGlobalBoundValidLifetime) {
|
||||
string crossed = "{ " + genIfaceConfig() + "," +
|
||||
"\"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 =
|
||||
@@ -1247,6 +1249,7 @@ TEST_F(Dhcp6ParserTest, outBoundPreferredLifetime) {
|
||||
" \"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: "
|
||||
@@ -1312,6 +1315,7 @@ TEST_F(Dhcp6ParserTest, outBoundGlobalPreferredLifetime) {
|
||||
string crossed = "{ " + genIfaceConfig() + "," +
|
||||
"\"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 =
|
||||
|
@@ -794,7 +794,7 @@ protected:
|
||||
/// @note: use overloading vs specialization because full specialization
|
||||
/// is not allowed in this scope.
|
||||
///
|
||||
/// @tparam IntType Type of the encapsulated value(s).
|
||||
/// @tparam NumType Type of the encapsulated value(s).
|
||||
///
|
||||
/// @param property Value to be returned when it is specified or when
|
||||
/// no global value is found.
|
||||
@@ -805,8 +805,8 @@ protected:
|
||||
///
|
||||
/// @return Optional value fetched from the global level or the value
|
||||
/// of @c property.
|
||||
template<typename IntType>
|
||||
Triplet<IntType> getGlobalProperty(Triplet<IntType> property,
|
||||
template<typename NumType>
|
||||
Triplet<NumType> getGlobalProperty(Triplet<NumType> property,
|
||||
const std::string& global_name,
|
||||
bool triplet) const {
|
||||
if (!global_name.empty() && fetch_globals_fn_) {
|
||||
@@ -814,23 +814,23 @@ protected:
|
||||
if (globals && (globals->getType() == data::Element::map)) {
|
||||
data::ConstElementPtr param = globals->get(global_name);
|
||||
if (param) {
|
||||
IntType def_value = static_cast<IntType>(param->intValue());
|
||||
NumType def_value = static_cast<NumType>(param->intValue());
|
||||
if (!triplet) {
|
||||
return (def_value);
|
||||
} else {
|
||||
IntType min_value = def_value;
|
||||
IntType max_value = def_value;
|
||||
NumType min_value = def_value;
|
||||
NumType max_value = def_value;
|
||||
const std::string& min_name = "min-" + global_name;
|
||||
data::ConstElementPtr min_param = globals->get(min_name);
|
||||
if (min_param) {
|
||||
min_value = static_cast<IntType>(min_param->intValue());
|
||||
min_value = static_cast<NumType>(min_param->intValue());
|
||||
}
|
||||
const std::string& max_name = "max-" + global_name;
|
||||
data::ConstElementPtr max_param = globals->get(max_name);
|
||||
if (min_param) {
|
||||
min_value = static_cast<IntType>(min_param->intValue());
|
||||
if (max_param) {
|
||||
max_value = static_cast<NumType>(max_param->intValue());
|
||||
}
|
||||
return (Triplet<IntType>(min_value, def_value, max_value));
|
||||
return (Triplet<NumType>(min_value, def_value, max_value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -740,28 +740,44 @@ TEST_F(NetworkReservationTest, move) {
|
||||
}
|
||||
|
||||
// This test verifies that the inheritance is supported for triplets.
|
||||
// Note that triplets have no comparison operator.
|
||||
TEST_F(NetworkTest, inheritanceTriplet) {
|
||||
NetworkPtr net(new Network());
|
||||
Triplet<uint32_t> empty;
|
||||
EXPECT_EQ(empty, net->getValid());
|
||||
EXPECT_EQ(empty, net->getValid(Network::Inheritance::ALL));
|
||||
EXPECT_EQ(empty, net->getValid(Network::Inheritance::GLOBAL));
|
||||
EXPECT_TRUE(net->getValid().unspecified());
|
||||
EXPECT_TRUE(net->getValid(Network::Inheritance::ALL).unspecified());
|
||||
EXPECT_TRUE(net->getValid(Network::Inheritance::GLOBAL).unspecified());
|
||||
|
||||
// Set valid lifetime global parameter.
|
||||
globals_->set("valid-lifetime", Element::create(200));
|
||||
net->setFetchGlobalsFn(getFetchGlobalsFn());
|
||||
Triplet<uint32_t> one(200);
|
||||
EXPECT_EQ(one, net->getValid());
|
||||
EXPECT_EQ(one, net->getValid(Network::Inheritance::ALL));
|
||||
EXPECT_EQ(one, net->getValid(Network::Inheritance::GLOBAL));
|
||||
EXPECT_FALSE(net->getValid().unspecified());
|
||||
EXPECT_FALSE(net->getValid(Network::Inheritance::ALL).unspecified());
|
||||
EXPECT_FALSE(net->getValid(Network::Inheritance::GLOBAL).unspecified());
|
||||
EXPECT_EQ(200, net->getValid().get());
|
||||
EXPECT_EQ(200, net->getValid(Network::Inheritance::ALL).get());
|
||||
EXPECT_EQ(200, net->getValid(Network::Inheritance::GLOBAL).get());
|
||||
EXPECT_EQ(200, net->getValid().getMin());
|
||||
EXPECT_EQ(200, net->getValid(Network::Inheritance::ALL).getMin());
|
||||
EXPECT_EQ(200, net->getValid(Network::Inheritance::GLOBAL).getMin());
|
||||
EXPECT_EQ(200, net->getValid().getMax());
|
||||
EXPECT_EQ(200, net->getValid(Network::Inheritance::ALL).getMax());
|
||||
EXPECT_EQ(200, net->getValid(Network::Inheritance::GLOBAL).getMax());
|
||||
|
||||
// Set all valid lifetime global parameters.
|
||||
globals_->set("min-valid-lifetime", Element::create(100));
|
||||
globals_->set("max-valid-lifetime", Element::create(300));
|
||||
Triplet<uint32_t> three(100, 200, 300);
|
||||
EXPECT_EQ(three, net->getValid());
|
||||
EXPECT_EQ(three, net->getValid(Network::Inheritance::ALL));
|
||||
EXPECT_EQ(three, net->getValid(Network::Inheritance::GLOBAL));
|
||||
EXPECT_FALSE(net->getValid().unspecified());
|
||||
EXPECT_FALSE(net->getValid(Network::Inheritance::ALL).unspecified());
|
||||
EXPECT_FALSE(net->getValid(Network::Inheritance::GLOBAL).unspecified());
|
||||
EXPECT_EQ(200, net->getValid().get());
|
||||
EXPECT_EQ(200, net->getValid(Network::Inheritance::ALL).get());
|
||||
EXPECT_EQ(200, net->getValid(Network::Inheritance::GLOBAL).get());
|
||||
EXPECT_EQ(100, net->getValid().getMin());
|
||||
EXPECT_EQ(100, net->getValid(Network::Inheritance::ALL).getMin());
|
||||
EXPECT_EQ(100, net->getValid(Network::Inheritance::GLOBAL).getMin());
|
||||
EXPECT_EQ(300, net->getValid().getMax());
|
||||
EXPECT_EQ(300, net->getValid(Network::Inheritance::ALL).getMax());
|
||||
EXPECT_EQ(300, net->getValid(Network::Inheritance::GLOBAL).getMax());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user