Commit 567fdab0 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[5114] Minor test improvements after review

parent fe07268a
...@@ -1165,7 +1165,7 @@ TEST_F(Dhcp6ParserTest, subnetLocal) { ...@@ -1165,7 +1165,7 @@ TEST_F(Dhcp6ParserTest, subnetLocal) {
TEST_F(Dhcp6ParserTest, subnetInterface) { TEST_F(Dhcp6ParserTest, subnetInterface) {
// There should be at least one interface // There should be at least one interface
// As far as I can tell, this is the first lambda in Kea code. Cool.
auto config = [this](string iface) { auto config = [this](string iface) {
return ("{ " + genIfaceConfig() + "," return ("{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000," "\"preferred-lifetime\": 3000,"
......
...@@ -703,21 +703,7 @@ public: ...@@ -703,21 +703,7 @@ public:
void runCfgOptionsTest(uint16_t family, std::string config) { void runCfgOptionsTest(uint16_t family, std::string config) {
ConstElementPtr json; ConstElementPtr json;
ASSERT_NO_THROW(json = Element::fromJSON(config)) << config; ASSERT_NO_THROW(json = Element::fromJSON(config)) << config;
ConstElementPtr option_def = json->get("option-def"); runCfgOptionsTest(family, json);
if (option_def) {
SimpleParser::setListDefaults(option_def,
family == AF_INET ?
ParseConfigTest::OPTION4_DEF_DEFAULTS :
ParseConfigTest::OPTION6_DEF_DEFAULTS);
}
ConstElementPtr option_data = json->get("option-data");
if (option_data) {
SimpleParser::setListDefaults(option_data,
family == AF_INET ?
ParseConfigTest::OPTION4_DEFAULTS :
ParseConfigTest::OPTION6_DEFAULTS);
}
runToElementTest<CfgOptionsTest>(json, *this);
} }
private: private:
......
...@@ -356,7 +356,7 @@ TEST_F(HostReservationParserTest, dhcp4ClientIdHexWithPrefix) { ...@@ -356,7 +356,7 @@ TEST_F(HostReservationParserTest, dhcp4ClientIdHexWithPrefix) {
// This test verifies that the parser can parse the reservation entry // This test verifies that the parser can parse the reservation entry
// when IPv4 address is specified, but hostname is not. // when IPv4 address is specified, but hostname is not.
TEST_F(HostReservationParserTest, dhcp4NoHostname) { TEST_F(HostReservationParserTest, dhcp4NoHostname) {
std::string config = "{ \"duid\": \"01:02:03:04:05:06:07:08:09:0A\"," std::string config = "{ \"duid\": \"01:02:03:04:05:06:07:08:09:0a\","
"\"ip-address\": \"192.0.2.10\" }"; "\"ip-address\": \"192.0.2.10\" }";
ElementPtr config_element = Element::fromJSON(config); ElementPtr config_element = Element::fromJSON(config);
...@@ -376,7 +376,6 @@ TEST_F(HostReservationParserTest, dhcp4NoHostname) { ...@@ -376,7 +376,6 @@ TEST_F(HostReservationParserTest, dhcp4NoHostname) {
EXPECT_TRUE(hosts[0]->getHostname().empty()); EXPECT_TRUE(hosts[0]->getHostname().empty());
// lower duid value // lower duid value
boost::algorithm::to_lower(config);
CfgMgr::instance().setFamily(AF_INET); CfgMgr::instance().setFamily(AF_INET);
CfgHostsSubnet cfg_subnet(cfg_hosts, SubnetID(10)); CfgHostsSubnet cfg_subnet(cfg_hosts, SubnetID(10));
runToElementTest<CfgHostsSubnet>("[" + config + "]", cfg_subnet); runToElementTest<CfgHostsSubnet>("[" + config + "]", cfg_subnet);
......
...@@ -60,6 +60,7 @@ TEST_F(IfacesConfigParserTest, interfaces) { ...@@ -60,6 +60,7 @@ TEST_F(IfacesConfigParserTest, interfaces) {
// Parse the configuration. // Parse the configuration.
IfacesConfigParser parser(AF_INET); IfacesConfigParser parser(AF_INET);
CfgIfacePtr cfg_iface = CfgMgr::instance().getStagingCfg()->getCfgIface(); CfgIfacePtr cfg_iface = CfgMgr::instance().getStagingCfg()->getCfgIface();
ASSERT_TRUE(cfg_iface);
ASSERT_NO_THROW(parser.parse(cfg_iface, config_element)); ASSERT_NO_THROW(parser.parse(cfg_iface, config_element));
// Check it can be unparsed. // Check it can be unparsed.
...@@ -84,6 +85,7 @@ TEST_F(IfacesConfigParserTest, interfaces) { ...@@ -84,6 +85,7 @@ TEST_F(IfacesConfigParserTest, interfaces) {
config_element = Element::fromJSON(config); config_element = Element::fromJSON(config);
cfg_iface = CfgMgr::instance().getStagingCfg()->getCfgIface(); cfg_iface = CfgMgr::instance().getStagingCfg()->getCfgIface();
ASSERT_TRUE(cfg_iface);
ASSERT_NO_THROW(parser.parse(cfg_iface, config_element)); ASSERT_NO_THROW(parser.parse(cfg_iface, config_element));
runToElementTest<CfgIface>(config, *cfg_iface); runToElementTest<CfgIface>(config, *cfg_iface);
...@@ -137,6 +139,7 @@ TEST_F(IfacesConfigParserTest, socketTypeDatagram) { ...@@ -137,6 +139,7 @@ TEST_F(IfacesConfigParserTest, socketTypeDatagram) {
// Parse the configuration. // Parse the configuration.
IfacesConfigParser parser(AF_INET); IfacesConfigParser parser(AF_INET);
CfgIfacePtr cfg_iface = CfgMgr::instance().getStagingCfg()->getCfgIface(); CfgIfacePtr cfg_iface = CfgMgr::instance().getStagingCfg()->getCfgIface();
ASSERT_TRUE(cfg_iface);
ASSERT_NO_THROW(parser.parse(cfg_iface, config_element)); ASSERT_NO_THROW(parser.parse(cfg_iface, config_element));
// Check it can be unparsed. // Check it can be unparsed.
...@@ -147,6 +150,7 @@ TEST_F(IfacesConfigParserTest, socketTypeDatagram) { ...@@ -147,6 +150,7 @@ TEST_F(IfacesConfigParserTest, socketTypeDatagram) {
SrvConfigPtr cfg = CfgMgr::instance().getStagingCfg(); SrvConfigPtr cfg = CfgMgr::instance().getStagingCfg();
ASSERT_TRUE(cfg); ASSERT_TRUE(cfg);
cfg_ref.useSocketType(AF_INET, CfgIface::SOCKET_UDP); cfg_ref.useSocketType(AF_INET, CfgIface::SOCKET_UDP);
ASSERT_TRUE(cfg->getCfgIface());
EXPECT_TRUE(*cfg->getCfgIface() == cfg_ref); EXPECT_TRUE(*cfg->getCfgIface() == cfg_ref);
} }
......
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