mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 05:55:28 +00:00
[#505] addressed review
This commit is contained in:
@@ -125,7 +125,7 @@ BaseNetworkParser::parseCommon(const ConstElementPtr& network_data,
|
|||||||
|
|
||||||
if (has_renew && has_rebind && (renew > rebind)) {
|
if (has_renew && has_rebind && (renew > rebind)) {
|
||||||
isc_throw(DhcpConfigError, "the value of renew-timer" << " (" << renew
|
isc_throw(DhcpConfigError, "the value of renew-timer" << " (" << renew
|
||||||
<< ") is not less than rebind-timer" << " (" << rebind << ")");
|
<< ") is greater than rebind-timer" << " (" << rebind << ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
network->setValid(parseLifetime(network_data, "valid-lifetime"));
|
network->setValid(parseLifetime(network_data, "valid-lifetime"));
|
||||||
|
@@ -760,14 +760,14 @@ Subnet4ConfigParser::initSubnet(data::ConstElementPtr params,
|
|||||||
renew = subnet4->getT1().get();
|
renew = subnet4->getT1().get();
|
||||||
output << "t1=" << renew << ", ";
|
output << "t1=" << renew << ", ";
|
||||||
}
|
}
|
||||||
if (rebind) {
|
if (has_rebind) {
|
||||||
rebind = subnet4->getT2().get();
|
rebind = subnet4->getT2().get();
|
||||||
output << "t2=" << rebind << ", ";
|
output << "t2=" << rebind << ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_renew && has_rebind && (renew > rebind)) {
|
if (has_renew && has_rebind && (renew > rebind)) {
|
||||||
isc_throw(DhcpConfigError, "the value of renew-timer" << " (" << renew
|
isc_throw(DhcpConfigError, "the value of renew-timer" << " (" << renew
|
||||||
<< ") is not less than rebind-timer" << " (" << rebind << ")");
|
<< ") is greater than rebind-timer" << " (" << rebind << ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!subnet4->getValid().unspecified()) {
|
if (!subnet4->getValid().unspecified()) {
|
||||||
@@ -1262,7 +1262,7 @@ Subnet6ConfigParser::initSubnet(data::ConstElementPtr params,
|
|||||||
|
|
||||||
if (has_renew && has_rebind && (renew > rebind)) {
|
if (has_renew && has_rebind && (renew > rebind)) {
|
||||||
isc_throw(DhcpConfigError, "the value of renew-timer" << " (" << renew
|
isc_throw(DhcpConfigError, "the value of renew-timer" << " (" << renew
|
||||||
<< ") is not less than rebind-timer" << " (" << rebind << ")");
|
<< ") is greater than rebind-timer" << " (" << rebind << ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!subnet6->getPreferred().unspecified()) {
|
if (!subnet6->getPreferred().unspecified()) {
|
||||||
|
@@ -474,14 +474,14 @@ TEST_F(SharedNetwork4ParserTest, iface) {
|
|||||||
TEST_F(SharedNetwork4ParserTest, parseWithInvalidRenewRebind) {
|
TEST_F(SharedNetwork4ParserTest, parseWithInvalidRenewRebind) {
|
||||||
IfaceMgrTestConfig ifmgr(true);
|
IfaceMgrTestConfig ifmgr(true);
|
||||||
|
|
||||||
// Basic configuration for shared network. A bunch of parameters
|
// Basic configuration for shared network.
|
||||||
// have to be specified for subnets because subnet parsers expect
|
|
||||||
// that default and global values are set.
|
|
||||||
std::string config = getWorkingConfig();
|
std::string config = getWorkingConfig();
|
||||||
ElementPtr config_element = Element::fromJSON(config);
|
ElementPtr config_element = Element::fromJSON(config);
|
||||||
ConstElementPtr valid_element = config_element->get("renew-timer");
|
ConstElementPtr valid_element = config_element->get("rebind-timer");
|
||||||
ElementPtr invalid_element = boost::const_pointer_cast<Element>(valid_element);
|
int64_t value = valid_element->intValue();
|
||||||
invalid_element->setValue(200);
|
valid_element = config_element->get("renew-timer");
|
||||||
|
ElementPtr mutable_element = boost::const_pointer_cast<Element>(valid_element);
|
||||||
|
mutable_element->setValue(value + 1);
|
||||||
|
|
||||||
// Parse configuration specified above.
|
// Parse configuration specified above.
|
||||||
SharedNetwork4Parser parser;
|
SharedNetwork4Parser parser;
|
||||||
@@ -491,6 +491,28 @@ TEST_F(SharedNetwork4ParserTest, parseWithInvalidRenewRebind) {
|
|||||||
ASSERT_FALSE(network);
|
ASSERT_FALSE(network);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This test verifies that shared network parser for IPv4 works properly
|
||||||
|
// when renew and rebind timers are equal.
|
||||||
|
TEST_F(SharedNetwork4ParserTest, parseValidWithEqualRenewRebind) {
|
||||||
|
IfaceMgrTestConfig ifmgr(true);
|
||||||
|
|
||||||
|
// Basic configuration for shared network.
|
||||||
|
std::string config = getWorkingConfig();
|
||||||
|
ElementPtr config_element = Element::fromJSON(config);
|
||||||
|
ConstElementPtr valid_element = config_element->get("rebind-timer");
|
||||||
|
int64_t value = valid_element->intValue();
|
||||||
|
valid_element = config_element->get("renew-timer");
|
||||||
|
ElementPtr mutable_element = boost::const_pointer_cast<Element>(valid_element);
|
||||||
|
mutable_element->setValue(value);
|
||||||
|
|
||||||
|
// Parse configuration specified above.
|
||||||
|
SharedNetwork4Parser parser;
|
||||||
|
SharedNetwork4Ptr network;
|
||||||
|
|
||||||
|
ASSERT_NO_THROW(network = parser.parse(config_element));
|
||||||
|
ASSERT_TRUE(network);
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Test fixture class for SharedNetwork6Parser class.
|
/// @brief Test fixture class for SharedNetwork6Parser class.
|
||||||
class SharedNetwork6ParserTest : public SharedNetworkParserTest {
|
class SharedNetwork6ParserTest : public SharedNetworkParserTest {
|
||||||
public:
|
public:
|
||||||
|
Reference in New Issue
Block a user