mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 05:27:55 +00:00
[#505] addressed review
This commit is contained in:
parent
7c8c11dc36
commit
3c2028c1aa
@ -125,7 +125,7 @@ BaseNetworkParser::parseCommon(const ConstElementPtr& network_data,
|
||||
|
||||
if (has_renew && has_rebind && (renew > rebind)) {
|
||||
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"));
|
||||
|
@ -760,14 +760,14 @@ Subnet4ConfigParser::initSubnet(data::ConstElementPtr params,
|
||||
renew = subnet4->getT1().get();
|
||||
output << "t1=" << renew << ", ";
|
||||
}
|
||||
if (rebind) {
|
||||
if (has_rebind) {
|
||||
rebind = subnet4->getT2().get();
|
||||
output << "t2=" << rebind << ", ";
|
||||
}
|
||||
|
||||
if (has_renew && has_rebind && (renew > rebind)) {
|
||||
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()) {
|
||||
@ -1262,7 +1262,7 @@ Subnet6ConfigParser::initSubnet(data::ConstElementPtr params,
|
||||
|
||||
if (has_renew && has_rebind && (renew > rebind)) {
|
||||
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()) {
|
||||
|
@ -474,14 +474,14 @@ TEST_F(SharedNetwork4ParserTest, iface) {
|
||||
TEST_F(SharedNetwork4ParserTest, parseWithInvalidRenewRebind) {
|
||||
IfaceMgrTestConfig ifmgr(true);
|
||||
|
||||
// Basic configuration for shared network. A bunch of parameters
|
||||
// have to be specified for subnets because subnet parsers expect
|
||||
// that default and global values are set.
|
||||
// Basic configuration for shared network.
|
||||
std::string config = getWorkingConfig();
|
||||
ElementPtr config_element = Element::fromJSON(config);
|
||||
ConstElementPtr valid_element = config_element->get("renew-timer");
|
||||
ElementPtr invalid_element = boost::const_pointer_cast<Element>(valid_element);
|
||||
invalid_element->setValue(200);
|
||||
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 + 1);
|
||||
|
||||
// Parse configuration specified above.
|
||||
SharedNetwork4Parser parser;
|
||||
@ -491,6 +491,28 @@ TEST_F(SharedNetwork4ParserTest, parseWithInvalidRenewRebind) {
|
||||
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.
|
||||
class SharedNetwork6ParserTest : public SharedNetworkParserTest {
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user