Commit d0af0733 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[5535] Minor changes after review:

 - improved tests for selectSubnet
 - improved hadAddresses
 - reinstantiated missing unit-test description
parent eb30390f
......@@ -4109,7 +4109,7 @@ TEST_F(Dhcp4ParserTest, subnetRelayInfoList) {
" \"rebind-timer\": 2, "
" \"valid-lifetime\": 4,"
" \"relay\": { "
" \"ip-addresses\": [ \"192.0.2.123\", \"192.0.2.124\" ]"
" \"ip-addresses\": [ \"192.0.3.123\", \"192.0.3.124\" ]"
" },"
" \"subnet\": \"192.0.2.0/24\" } ],"
"\"valid-lifetime\": 4000 }";
......@@ -4123,13 +4123,16 @@ TEST_F(Dhcp4ParserTest, subnetRelayInfoList) {
// returned value should be 0 (configuration success)
checkResult(status, 0);
SubnetSelector selector;
selector.giaddr_ = IOAddress("192.0.2.200");
Subnet4Ptr subnet = CfgMgr::instance().getStagingCfg()->
getCfgSubnets4()->selectSubnet(IOAddress("192.0.2.200"));
getCfgSubnets4()->selectSubnet(selector);
ASSERT_TRUE(subnet);
EXPECT_TRUE(subnet->hasRelays());
EXPECT_TRUE(subnet->hasRelayAddress(IOAddress("192.0.2.123")));
EXPECT_TRUE(subnet->hasRelayAddress(IOAddress("192.0.2.124")));
EXPECT_TRUE(subnet->hasRelayAddress(IOAddress("192.0.3.123")));
EXPECT_TRUE(subnet->hasRelayAddress(IOAddress("192.0.3.124")));
}
......
......@@ -4156,7 +4156,7 @@ TEST_F(Dhcp6ParserTest, subnetRelayInfoList) {
"\"subnet6\": [ { "
" \"pools\": [ { \"pool\": \"2001:db8:1::1 - 2001:db8:1::ffff\" } ],"
" \"relay\": { "
" \"ip-addresses\": [ \"2001:db8:1::abcd\", \"2001:db8:1::abce\" ]"
" \"ip-addresses\": [ \"2001:db9::abcd\", \"2001:db9::abce\" ]"
" },"
" \"subnet\": \"2001:db8:1::/64\" } ],"
"\"preferred-lifetime\": 3000, "
......@@ -4173,12 +4173,12 @@ TEST_F(Dhcp6ParserTest, subnetRelayInfoList) {
checkResult(status, 0);
Subnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->
selectSubnet(IOAddress("2001:db8:1::1"), classify_);
selectSubnet(IOAddress("2001:db9::abcd"), classify_, true);
ASSERT_TRUE(subnet);
EXPECT_TRUE(subnet->hasRelays());
EXPECT_TRUE(subnet->hasRelayAddress(IOAddress("2001:db8:1::abcd")));
EXPECT_TRUE(subnet->hasRelayAddress(IOAddress("2001:db8:1::abce")));
EXPECT_TRUE(subnet->hasRelayAddress(IOAddress("2001:db9::abcd")));
EXPECT_TRUE(subnet->hasRelayAddress(IOAddress("2001:db9::abce")));
}
// Goal of this test is to verify that multiple subnets can be configured
......
......@@ -28,7 +28,7 @@ Network::RelayInfo::addAddress(const asiolink::IOAddress& addr) {
bool
Network::RelayInfo::hasAddresses() const {
return (addresses_.size() > 0);
return (!addresses_.empty());
}
bool
......
......@@ -244,6 +244,8 @@ TEST_F(SharedNetwork4ParserTest, missingName) {
ASSERT_THROW(network = parser.parse(config_element), DhcpConfigError);
}
// This test verifies that it's possible to specify client-class
// and match-client-id on shared-network level.
TEST_F(SharedNetwork4ParserTest, clientClassMatchClientId) {
std::string config = getWorkingConfig();
ElementPtr config_element = Element::fromJSON(config);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment