" \"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: "
/// 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 }";
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 =
" \"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: "
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 =
/// @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.
///
/// @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_) {
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));
}
}
}
}
// 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());
}
}