Skip to content

Commit 8c9af66

Browse files
author
Razvan Becheriu
committed
[#2974] add more unittests
1 parent 495a537 commit 8c9af66

4 files changed

+126
-0
lines changed

src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc

+28
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,34 @@ TEST_F(CtrlChannelDhcpv4SrvTest, configTest) {
10351035
CfgMgr::instance().clear();
10361036
}
10371037

1038+
// Verify that the "subnet4-select-test" command will do what we expect.
1039+
TEST_F(CtrlChannelDhcpv4SrvTest, subnetSelectTest) {
1040+
createUnixChannelServer();
1041+
1042+
string command_txt = "{ \"command\": \"subnet4-select-test\", \"arguments\": { \"classes\": [ \"foo\" ] } }";
1043+
1044+
// Send the subnet4-select-test command
1045+
std::string response;
1046+
sendUnixCommand(command_txt, response);
1047+
1048+
EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }",
1049+
response);
1050+
}
1051+
1052+
// Verify that the "subnet4o6-select-test" command will do what we expect.
1053+
TEST_F(CtrlChannelDhcpv4SrvTest, subnet4o6SelectTest) {
1054+
createUnixChannelServer();
1055+
1056+
string command_txt = "{ \"command\": \"subnet4o6-select-test\", \"arguments\": { \"classes\": [ \"foo\" ] } }";
1057+
1058+
// Send the subnet4o6-select-test command
1059+
std::string response;
1060+
sendUnixCommand(command_txt, response);
1061+
1062+
EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }",
1063+
response);
1064+
}
1065+
10381066
// This test verifies that the DHCP server handles version-get commands
10391067
TEST_F(CtrlChannelDhcpv4SrvTest, getVersion) {
10401068
createUnixChannelServer();

src/bin/dhcp4/tests/http_control_socket_unittest.cc

+56
Original file line numberDiff line numberDiff line change
@@ -1663,6 +1663,62 @@ TEST_F(HttpsCtrlChannelDhcpv4Test, configTest) {
16631663
CfgMgr::instance().clear();
16641664
}
16651665

1666+
// Verify that the "subnet4-select-test" command will do what we expect.
1667+
TEST_F(HttpCtrlChannelDhcpv4Test, subnetSelectTest) {
1668+
createHttpChannelServer();
1669+
1670+
string command_txt = "{ \"command\": \"subnet4-select-test\", \"arguments\": { \"classes\": [ \"foo\" ] } }";
1671+
1672+
// Send the subnet4-select-test command
1673+
std::string response;
1674+
sendHttpCommand(command_txt, response);
1675+
1676+
EXPECT_EQ("[ { \"result\": 3, \"text\": \"no subnet selected\" } ]",
1677+
response);
1678+
}
1679+
1680+
// Verify that the "subnet4-select-test" command will do what we expect.
1681+
TEST_F(HttpsCtrlChannelDhcpv4Test, subnetSelectTest) {
1682+
createHttpChannelServer();
1683+
1684+
string command_txt = "{ \"command\": \"subnet4-select-test\", \"arguments\": { \"classes\": [ \"foo\" ] } }";
1685+
1686+
// Send the subnet4-select-test command
1687+
std::string response;
1688+
sendHttpCommand(command_txt, response);
1689+
1690+
EXPECT_EQ("[ { \"result\": 3, \"text\": \"no subnet selected\" } ]",
1691+
response);
1692+
}
1693+
1694+
// Verify that the "subnet4o6-select-test" command will do what we expect.
1695+
TEST_F(HttpCtrlChannelDhcpv4Test, subnet4o6SelectTest) {
1696+
createHttpChannelServer();
1697+
1698+
string command_txt = "{ \"command\": \"subnet4o6-select-test\", \"arguments\": { \"classes\": [ \"foo\" ] } }";
1699+
1700+
// Send the subnet4o6-select-test command
1701+
std::string response;
1702+
sendHttpCommand(command_txt, response);
1703+
1704+
EXPECT_EQ("[ { \"result\": 3, \"text\": \"no subnet selected\" } ]",
1705+
response);
1706+
}
1707+
1708+
// Verify that the "subnet4o6-select-test" command will do what we expect.
1709+
TEST_F(HttpsCtrlChannelDhcpv4Test, subnet4o6SelectTest) {
1710+
createHttpChannelServer();
1711+
1712+
string command_txt = "{ \"command\": \"subnet4o6-select-test\", \"arguments\": { \"classes\": [ \"foo\" ] } }";
1713+
1714+
// Send the subnet4o6-select-test command
1715+
std::string response;
1716+
sendHttpCommand(command_txt, response);
1717+
1718+
EXPECT_EQ("[ { \"result\": 3, \"text\": \"no subnet selected\" } ]",
1719+
response);
1720+
}
1721+
16661722
// This test verifies that the DHCP server handles version-get commands.
16671723
void
16681724
BaseCtrlChannelDhcpv4Test::testGetVersion() {

src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc

+14
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,20 @@ TEST_F(CtrlChannelDhcpv6SrvTest, configTest) {
10661066
CfgMgr::instance().clear();
10671067
}
10681068

1069+
// Verify that the "subnet6-select-test" command will do what we expect.
1070+
TEST_F(CtrlChannelDhcpv6SrvTest, subnetSelectTest) {
1071+
createUnixChannelServer();
1072+
1073+
string command_txt = "{ \"command\": \"subnet6-select-test\", \"arguments\": { \"classes\": [ \"foo\" ] } }";
1074+
1075+
// Send the subnet6-select-test command
1076+
std::string response;
1077+
sendUnixCommand(command_txt, response);
1078+
1079+
EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }",
1080+
response);
1081+
}
1082+
10691083
// This test verifies that the DHCP server handles version-get commands
10701084
TEST_F(CtrlChannelDhcpv6SrvTest, getVersion) {
10711085
createUnixChannelServer();

src/bin/dhcp6/tests/http_control_socket_unittest.cc

+28
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,34 @@ TEST_F(HttpsCtrlChannelDhcpv6Test, configTest) {
16971697
CfgMgr::instance().clear();
16981698
}
16991699

1700+
// Verify that the "subnet6-select-test" command will do what we expect.
1701+
TEST_F(HttpCtrlChannelDhcpv6Test, subnetSelectTest) {
1702+
createHttpChannelServer();
1703+
1704+
string command_txt = "{ \"command\": \"subnet6-select-test\", \"arguments\": { \"classes\": [ \"foo\" ] } }";
1705+
1706+
// Send the subnet6-select-test command
1707+
std::string response;
1708+
sendHttpCommand(command_txt, response);
1709+
1710+
EXPECT_EQ("[ { \"result\": 3, \"text\": \"no subnet selected\" } ]",
1711+
response);
1712+
}
1713+
1714+
// Verify that the "subnet6-select-test" command will do what we expect.
1715+
TEST_F(HttpsCtrlChannelDhcpv6Test, subnetSelectTest) {
1716+
createHttpChannelServer();
1717+
1718+
string command_txt = "{ \"command\": \"subnet6-select-test\", \"arguments\": { \"classes\": [ \"foo\" ] } }";
1719+
1720+
// Send the subnet6-select-test command
1721+
std::string response;
1722+
sendHttpCommand(command_txt, response);
1723+
1724+
EXPECT_EQ("[ { \"result\": 3, \"text\": \"no subnet selected\" } ]",
1725+
response);
1726+
}
1727+
17001728
// This test verifies that the DHCP server handles version-get commands.
17011729
void
17021730
BaseCtrlChannelDhcpv6Test::testGetVersion() {

0 commit comments

Comments
 (0)