]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#39,!108] Unit-tests updated
authorTomek Mrugalski <tomasz@isc.org>
Wed, 31 Oct 2018 18:58:22 +0000 (19:58 +0100)
committerTomek Mrugalski <tomasz@isc.org>
Wed, 31 Oct 2018 18:58:22 +0000 (19:58 +0100)
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/shared_network_unittest.cc
src/bin/dhcp6/tests/classify_unittests.cc
src/bin/dhcp6/tests/shared_network_unittest.cc

index 0859cac68d1fa6e6e23031785d7ec7fab7e27a6b..d8064694a71c09439c4dbf6dd639cb3d36ce3a25 100644 (file)
@@ -2145,7 +2145,7 @@ TEST_F(Dhcpv4SrvTest, matchClassificationOptionDef) {
     EXPECT_TRUE(query->inClass("router"));
 }
 
-// Checks subnet options have the priority over class options
+// Checks class options have the priority over subnet options
 TEST_F(Dhcpv4SrvTest, subnetClassPriority) {
     IfaceMgrTestConfig test_config(true);
     IfaceMgr::instance().openSockets4();
@@ -2165,12 +2165,12 @@ TEST_F(Dhcpv4SrvTest, subnetClassPriority) {
         "    \"subnet\": \"192.0.2.0/24\", "
         "    \"option-data\": ["
         "        {    \"name\": \"ip-forwarding\", "
-        "             \"data\": \"false\" } ] } ], "
+        "             \"data\": \"true\" } ] } ], "
         "\"client-classes\": [ "
         "{   \"name\": \"router\","
         "    \"option-data\": ["
         "        {    \"name\": \"ip-forwarding\", "
-        "             \"data\": \"true\" } ], "
+        "             \"data\": \"false\" } ], "
         "    \"test\": \"option[12].text == 'foo'\" } ] }";
 
     ConstElementPtr json;
index 7afcbe2077f33545879334b420fb950bf3fe09d9..9c7eb68eb7dbb56d6d6e10b0ecbafcd5bc222ce6 100644 (file)
@@ -2121,7 +2121,7 @@ TEST_F(Dhcpv4SharedNetworkTest, poolInSubnetSelectedByClass) {
 }
 
 // Verify option processing precedence
-// Order is global < class < shared-network < subnet < pool < host reservation
+// Order is global < shared-network < subnet < pool < class < host reservation
 TEST_F(Dhcpv4SharedNetworkTest, precedenceGlobal) {
     const std::string config =
         "{"
@@ -2164,7 +2164,7 @@ TEST_F(Dhcpv4SharedNetworkTest, precedenceGlobal) {
 }
 
 // Verify option processing precedence
-// Order is global < class < shared-network < subnet < pool < host reservation
+// Order is global < shared-network < subnet < pool < class < host reservation
 TEST_F(Dhcpv4SharedNetworkTest, precedenceClass) {
     const std::string config =
         "{"
@@ -2219,7 +2219,7 @@ TEST_F(Dhcpv4SharedNetworkTest, precedenceClass) {
 }
 
 // Verify option processing precedence
-// Order is global < class < shared-network < subnet < pool < host reservation
+// Order is global < shared-network < subnet < pool < class < host reservation
 TEST_F(Dhcpv4SharedNetworkTest, precedenceClasses) {
     const std::string config =
         "{"
@@ -2259,13 +2259,31 @@ TEST_F(Dhcpv4SharedNetworkTest, precedenceClasses) {
         "        {"
         "            \"name\": \"frog\","
         "            \"interface\": \"eth1\","
+        "            \"option-data\": ["
+        "                {"
+        "                   \"name\": \"domain-name-servers\","
+        "                   \"data\": \"192.0.2.4\""
+        "                }"
+        "            ],"
         "            \"subnet4\": ["
         "                {"
         "                    \"subnet\": \"192.0.2.0/26\","
         "                    \"id\": 10,"
+        "                    \"option-data\": ["
+        "                        {"
+        "                           \"name\": \"domain-name-servers\","
+        "                           \"data\": \"192.0.2.5\""
+        "                        }"
+        "                    ],"
         "                    \"pools\": ["
         "                        {"
-        "                            \"pool\": \"192.0.2.1 - 192.0.2.63\""
+        "                            \"pool\": \"192.0.2.1 - 192.0.2.63\","
+        "                            \"option-data\": ["
+        "                                {"
+        "                                   \"name\": \"domain-name-servers\","
+        "                                   \"data\": \"192.0.2.5\""
+        "                                }"
+        "                            ]"
         "                        }"
         "                    ],"
         "                    \"reservations\": ["
@@ -2285,7 +2303,7 @@ TEST_F(Dhcpv4SharedNetworkTest, precedenceClasses) {
 }
 
 // Verify option processing precedence
-// Order is global < class < shared-network < subnet < pool < host reservation
+// Order is global < shared-network < subnet < pool < class < host reservation
 TEST_F(Dhcpv4SharedNetworkTest, precedenceNetwork) {
     const std::string config =
         "{"
@@ -2299,18 +2317,6 @@ TEST_F(Dhcpv4SharedNetworkTest, precedenceNetwork) {
         "           \"data\": \"192.0.2.1\""
         "        }"
         "    ],"
-        "    \"client-classes\": ["
-        "        {"
-        "            \"name\": \"alpha\","
-        "            \"test\": \"'' == ''\","
-        "            \"option-data\": ["
-        "                {"
-        "                   \"name\": \"domain-name-servers\","
-        "                   \"data\": \"192.0.2.2\""
-        "                }"
-        "            ]"
-        "        }"
-        "    ],"
         "    \"shared-networks\": ["
         "        {"
         "            \"name\": \"frog\","
@@ -2346,7 +2352,7 @@ TEST_F(Dhcpv4SharedNetworkTest, precedenceNetwork) {
 }
 
 // Verify option processing precedence
-// Order is global < class < shared-network < subnet < pool < host reservation
+// Order is global < shared-network < subnet < pool < class < host reservation
 TEST_F(Dhcpv4SharedNetworkTest, precedenceSubnet) {
     const std::string config =
         "{"
@@ -2360,18 +2366,6 @@ TEST_F(Dhcpv4SharedNetworkTest, precedenceSubnet) {
         "           \"data\": \"192.0.2.1\""
         "        }"
         "    ],"
-        "    \"client-classes\": ["
-        "        {"
-        "            \"name\": \"alpha\","
-        "            \"test\": \"'' == ''\","
-        "            \"option-data\": ["
-        "                {"
-        "                   \"name\": \"domain-name-servers\","
-        "                   \"data\": \"192.0.2.2\""
-        "                }"
-        "            ]"
-        "        }"
-        "    ],"
         "    \"shared-networks\": ["
         "        {"
         "            \"name\": \"frog\","
@@ -2413,7 +2407,7 @@ TEST_F(Dhcpv4SharedNetworkTest, precedenceSubnet) {
 }
 
 // Verify option processing precedence
-// Order is global < class < shared-network < subnet < pool < host reservation
+// Order is global < shared-network < subnet < pool < class < host reservation
 TEST_F(Dhcpv4SharedNetworkTest, precedencePool) {
     const std::string config =
         "{"
@@ -2427,18 +2421,6 @@ TEST_F(Dhcpv4SharedNetworkTest, precedencePool) {
         "           \"data\": \"192.0.2.1\""
         "        }"
         "    ],"
-        "    \"client-classes\": ["
-        "        {"
-        "            \"name\": \"alpha\","
-        "            \"test\": \"'' == ''\","
-        "            \"option-data\": ["
-        "                {"
-        "                   \"name\": \"domain-name-servers\","
-        "                   \"data\": \"192.0.2.2\""
-        "                }"
-        "            ]"
-        "        }"
-        "    ],"
         "    \"shared-networks\": ["
         "        {"
         "            \"name\": \"frog\","
@@ -2486,7 +2468,7 @@ TEST_F(Dhcpv4SharedNetworkTest, precedencePool) {
 }
 
 // Verify option processing precedence
-// Order is global < class < shared-network < subnet < pool < host reservation
+// Order is global < shared-network < subnet < pool < class < host reservation
 TEST_F(Dhcpv4SharedNetworkTest, precedenceReservation) {
     const std::string config =
         "{"
index 9620874853349d116198018c320e05c1eebae131..cb6a69f5f207e6e70e656a069895e9b472a7790a 100644 (file)
@@ -687,12 +687,12 @@ TEST_F(ClassifyTest, subnetClassPriority) {
         "    \"interface\": \"eth1\", "
         "    \"option-data\": ["
         "        {    \"name\": \"ipv6-forwarding\", "
-        "             \"data\": \"false\" } ] } ], "
+        "             \"data\": \"true\" } ] } ], "
         "\"client-classes\": [ "
         "{   \"name\": \"router\","
         "    \"option-data\": ["
         "        {    \"name\": \"ipv6-forwarding\", "
-        "             \"data\": \"true\" } ], "
+        "             \"data\": \"false\" } ], "
         "    \"test\": \"option[1234].text == 'foo'\" } ] }";
     ASSERT_NO_THROW(configure(config));
 
index 7ffe9fc24d9c5c067cae257e355d47afc612855d..d55236260b100f4c2e706c6d0643937a73447402 100644 (file)
@@ -2499,7 +2499,7 @@ TEST_F(Dhcpv6SharedNetworkTest, poolInSubnetSelectedByClass) {
 }
 
 // Verify option processing precedence
-// Order is global < class < shared-network < subnet < pools < host reservation
+// Order is global < shared-network < subnet < pools < class < host reservation
 TEST_F(Dhcpv6SharedNetworkTest, precedenceGlobal) {
     const std::string config =
         "{"
@@ -2538,7 +2538,7 @@ TEST_F(Dhcpv6SharedNetworkTest, precedenceGlobal) {
 }
 
 // Verify option processing precedence
-// Order is global < class < shared-network < subnet < pools < host reservation
+// Order is global < shared-network < subnet < pools < class < host reservation
 TEST_F(Dhcpv6SharedNetworkTest, precedenceClass) {
     const std::string config =
         "{"
@@ -2589,7 +2589,7 @@ TEST_F(Dhcpv6SharedNetworkTest, precedenceClass) {
 }
 
 // Verify option processing precedence
-// Order is global < class < shared-network < subnet < pools < host reservation
+// Order is global < shared-network < subnet < pools < class < host reservation
 TEST_F(Dhcpv6SharedNetworkTest, precedenceClasses) {
     const std::string config =
         "{"
@@ -2651,8 +2651,8 @@ TEST_F(Dhcpv6SharedNetworkTest, precedenceClasses) {
 }
 
 // Verify option processing precedence
-// Order is global < class < shared-network < subnet < pools < host reservation
-TEST_F(Dhcpv6SharedNetworkTest, precedenceNetworkClass) {
+// Order is global < shared-network < subnet < pools < class < host reservation
+TEST_F(Dhcpv6SharedNetworkTest, precedencePoolClass) {
     const std::string config =
         "{"
         "    \"option-data\": ["
@@ -2689,7 +2689,13 @@ TEST_F(Dhcpv6SharedNetworkTest, precedenceNetworkClass) {
         "                    \"id\": 10,"
         "                    \"pools\": ["
         "                        {"
-        "                            \"pool\": \"2001:db8:1::1 - 2001:db8:1::64\""
+        "                            \"pool\": \"2001:db8:1::1 - 2001:db8:1::64\","
+        "                            \"option-data\": ["
+        "                                {"
+        "                                   \"name\": \"dns-servers\","
+        "                                   \"data\": \"2001:db8:1::4\""
+        "                                }"
+        "                            ]"
         "                        }"
         "                    ],"
         "                    \"reservations\": ["
@@ -2704,11 +2710,11 @@ TEST_F(Dhcpv6SharedNetworkTest, precedenceNetworkClass) {
         "    ]"
         "}";
 
-    testPrecedence(config, "2001:db8:1::3");
+    testPrecedence(config, "2001:db8:1::2");
 }
 
 // Verify option processing precedence
-// Order is global < class < shared-network < subnet < pools < host reservation
+// Order is global < shared-network < subnet < pools < class < host reservation
 TEST_F(Dhcpv6SharedNetworkTest, precedenceSubnet) {
     const std::string config =
         "{"
@@ -2718,18 +2724,6 @@ TEST_F(Dhcpv6SharedNetworkTest, precedenceSubnet) {
         "           \"data\": \"2001:db8:1::1\""
         "        }"
         "    ],"
-        "    \"client-classes\": ["
-        "        {"
-        "            \"name\": \"alpha\","
-        "            \"test\": \"'' == ''\","
-        "            \"option-data\": ["
-        "                {"
-        "                   \"name\": \"dns-servers\","
-        "                   \"data\": \"2001:db8:1::2\""
-        "                }"
-        "            ]"
-        "        }"
-        "    ],"
         "    \"shared-networks\": ["
         "        {"
         "            \"name\": \"frog\","
@@ -2771,7 +2765,7 @@ TEST_F(Dhcpv6SharedNetworkTest, precedenceSubnet) {
 }
 
 // Verify option processing precedence
-// Order is global < class < shared-network < subnet < pools < host reservation
+// Order is global < shared-network < subnet < pools < class < host reservation
 TEST_F(Dhcpv6SharedNetworkTest, precedencePool) {
     const std::string config =
         "{"
@@ -2781,18 +2775,6 @@ TEST_F(Dhcpv6SharedNetworkTest, precedencePool) {
         "           \"data\": \"2001:db8:1::1\""
         "        }"
         "    ],"
-        "    \"client-classes\": ["
-        "        {"
-        "            \"name\": \"alpha\","
-        "            \"test\": \"'' == ''\","
-        "            \"option-data\": ["
-        "                {"
-        "                   \"name\": \"dns-servers\","
-        "                   \"data\": \"2001:db8:1::2\""
-        "                }"
-        "            ]"
-        "        }"
-        "    ],"
         "    \"shared-networks\": ["
         "        {"
         "            \"name\": \"frog\","
@@ -2840,7 +2822,7 @@ TEST_F(Dhcpv6SharedNetworkTest, precedencePool) {
 }
 
 // Verify option processing precedence
-// Order is global < class < shared-network < subnet < pools < host reservation
+// Order is global < shared-network < subnet < pools < class < host reservation
 TEST_F(Dhcpv6SharedNetworkTest, precedenceReservation) {
     const std::string config =
         "{"