Skip to content

Commit

Permalink
[#3590] Checkpoint: updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fxdupont committed Oct 7, 2024
1 parent 069f152 commit 3b0d99d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 75 deletions.
58 changes: 21 additions & 37 deletions src/bin/dhcp4/tests/classify_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ TEST_F(ClassifyTest, server2computer) {
}

// This test checks the precedence order in required evaluation.
// This order is: shared-network > subnet > pools
// This order is: pools > subnet > shared-network
TEST_F(ClassifyTest, precedenceNone) {
std::string config =
"{"
Expand All @@ -953,12 +953,8 @@ TEST_F(ClassifyTest, precedenceNone) {
"\"valid-lifetime\": 600,"
"\"client-classes\": ["
" {"
" \"name\": \"all\","
" \"test\": \"'' == ''\""
" },"
" {"
" \"name\": \"for-pool\","
" \"test\": \"member('all')\","
" \"test\": \"member('ALL')\","
" \"only-if-required\": true,"
" \"option-data\": [ {"
" \"name\": \"domain-name-servers\","
Expand All @@ -967,7 +963,7 @@ TEST_F(ClassifyTest, precedenceNone) {
" },"
" {"
" \"name\": \"for-subnet\","
" \"test\": \"member('all')\","
" \"test\": \"member('ALL')\","
" \"only-if-required\": true,"
" \"option-data\": [ {"
" \"name\": \"domain-name-servers\","
Expand All @@ -976,7 +972,7 @@ TEST_F(ClassifyTest, precedenceNone) {
" },"
" {"
" \"name\": \"for-network\","
" \"test\": \"member('all')\","
" \"test\": \"member('ALL')\","
" \"only-if-required\": true,"
" \"option-data\": [ {"
" \"name\": \"domain-name-servers\","
Expand Down Expand Up @@ -1015,7 +1011,7 @@ TEST_F(ClassifyTest, precedenceNone) {
}

// This test checks the precedence order in required evaluation.
// This order is: shared-network > subnet > pools
// This order is: pools > subnet > shared-network
TEST_F(ClassifyTest, precedencePool) {
std::string config =
"{"
Expand All @@ -1025,12 +1021,8 @@ TEST_F(ClassifyTest, precedencePool) {
"\"valid-lifetime\": 600,"
"\"client-classes\": ["
" {"
" \"name\": \"all\","
" \"test\": \"'' == ''\""
" },"
" {"
" \"name\": \"for-pool\","
" \"test\": \"member('all')\","
" \"test\": \"member('ALL')\","
" \"only-if-required\": true,"
" \"option-data\": [ {"
" \"name\": \"domain-name-servers\","
Expand All @@ -1039,7 +1031,7 @@ TEST_F(ClassifyTest, precedencePool) {
" },"
" {"
" \"name\": \"for-subnet\","
" \"test\": \"member('all')\","
" \"test\": \"member('ALL')\","
" \"only-if-required\": true,"
" \"option-data\": [ {"
" \"name\": \"domain-name-servers\","
Expand All @@ -1048,7 +1040,7 @@ TEST_F(ClassifyTest, precedencePool) {
" },"
" {"
" \"name\": \"for-network\","
" \"test\": \"member('all')\","
" \"test\": \"member('ALL')\","
" \"only-if-required\": true,"
" \"option-data\": [ {"
" \"name\": \"domain-name-servers\","
Expand All @@ -1058,9 +1050,11 @@ TEST_F(ClassifyTest, precedencePool) {
"],"
"\"shared-networks\": [ {"
" \"name\": \"frog\","
" \"require-client-classes\": [ \"for-network\" ],"
" \"subnet4\": [ { "
" \"subnet\": \"10.0.0.0/24\","
" \"id\": 1,"
" \"require-client-classes\": [ \"for-subnet\" ],"
" \"pools\": [ { "
" \"pool\": \"10.0.0.10-10.0.0.100\","
" \"require-client-classes\": [ \"for-pool\" ]"
Expand Down Expand Up @@ -1094,7 +1088,7 @@ TEST_F(ClassifyTest, precedencePool) {
}

// This test checks the precedence order in required evaluation.
// This order is: shared-network > subnet > pools
// This order is: pools > subnet > shared-network
TEST_F(ClassifyTest, precedenceSubnet) {
std::string config =
"{"
Expand All @@ -1104,12 +1098,8 @@ TEST_F(ClassifyTest, precedenceSubnet) {
"\"valid-lifetime\": 600,"
"\"client-classes\": ["
" {"
" \"name\": \"all\","
" \"test\": \"'' == ''\""
" },"
" {"
" \"name\": \"for-pool\","
" \"test\": \"member('all')\","
" \"test\": \"member('ALL')\","
" \"only-if-required\": true,"
" \"option-data\": [ {"
" \"name\": \"domain-name-servers\","
Expand All @@ -1118,7 +1108,7 @@ TEST_F(ClassifyTest, precedenceSubnet) {
" },"
" {"
" \"name\": \"for-subnet\","
" \"test\": \"member('all')\","
" \"test\": \"member('ALL')\","
" \"only-if-required\": true,"
" \"option-data\": [ {"
" \"name\": \"domain-name-servers\","
Expand All @@ -1127,7 +1117,7 @@ TEST_F(ClassifyTest, precedenceSubnet) {
" },"
" {"
" \"name\": \"for-network\","
" \"test\": \"member('all')\","
" \"test\": \"member('ALL')\","
" \"only-if-required\": true,"
" \"option-data\": [ {"
" \"name\": \"domain-name-servers\","
Expand All @@ -1137,13 +1127,13 @@ TEST_F(ClassifyTest, precedenceSubnet) {
"],"
"\"shared-networks\": [ {"
" \"name\": \"frog\","
" \"require-client-classes\": [ \"for-network\" ],"
" \"subnet4\": [ { "
" \"subnet\": \"10.0.0.0/24\","
" \"id\": 1,"
" \"require-client-classes\": [ \"for-subnet\" ],"
" \"pools\": [ { "
" \"pool\": \"10.0.0.10-10.0.0.100\","
" \"require-client-classes\": [ \"for-pool\" ]"
" \"pool\": \"10.0.0.10-10.0.0.100\""
" } ]"
" } ]"
"} ]"
Expand Down Expand Up @@ -1174,7 +1164,7 @@ TEST_F(ClassifyTest, precedenceSubnet) {
}

// This test checks the precedence order in required evaluation.
// This order is: shared-network > subnet > pools
// This order is: pools > subnet > shared-network
TEST_F(ClassifyTest, precedenceNetwork) {
std::string config =
"{"
Expand All @@ -1184,12 +1174,8 @@ TEST_F(ClassifyTest, precedenceNetwork) {
"\"valid-lifetime\": 600,"
"\"client-classes\": ["
" {"
" \"name\": \"all\","
" \"test\": \"'' == ''\""
" },"
" {"
" \"name\": \"for-pool\","
" \"test\": \"member('all')\","
" \"test\": \"member('ALL')\","
" \"only-if-required\": true,"
" \"option-data\": [ {"
" \"name\": \"domain-name-servers\","
Expand All @@ -1198,7 +1184,7 @@ TEST_F(ClassifyTest, precedenceNetwork) {
" },"
" {"
" \"name\": \"for-subnet\","
" \"test\": \"member('all')\","
" \"test\": \"member('ALL')\","
" \"only-if-required\": true,"
" \"option-data\": [ {"
" \"name\": \"domain-name-servers\","
Expand All @@ -1207,7 +1193,7 @@ TEST_F(ClassifyTest, precedenceNetwork) {
" },"
" {"
" \"name\": \"for-network\","
" \"test\": \"member('all')\","
" \"test\": \"member('ALL')\","
" \"only-if-required\": true,"
" \"option-data\": [ {"
" \"name\": \"domain-name-servers\","
Expand All @@ -1221,10 +1207,8 @@ TEST_F(ClassifyTest, precedenceNetwork) {
" \"subnet4\": [ { "
" \"subnet\": \"10.0.0.0/24\","
" \"id\": 1,"
" \"require-client-classes\": [ \"for-subnet\" ],"
" \"pools\": [ { "
" \"pool\": \"10.0.0.10-10.0.0.100\","
" \"require-client-classes\": [ \"for-pool\" ]"
" \"pool\": \"10.0.0.10-10.0.0.100\""
" } ]"
" } ]"
"} ]"
Expand Down
2 changes: 1 addition & 1 deletion src/bin/dhcp6/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ PROGRAM_TESTS = dhcp6_unittests
# This list is ordered alphabetically. When adding new files, please maintain
# this order.
dhcp6_unittests_SOURCES =
dhcp6_unittests_SOURCES += classify_unittests.cc
dhcp6_unittests_SOURCES += classify_unittest.cc
dhcp6_unittests_SOURCES += client_handler_unittest.cc
dhcp6_unittests_SOURCES += config_parser_unittest.cc
dhcp6_unittests_SOURCES += config_backend_unittest.cc
Expand Down
Loading

0 comments on commit 3b0d99d

Please sign in to comment.