]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2028] Correct test config backend logic
authorMarcin Siodelski <marcin@isc.org>
Thu, 16 Sep 2021 11:58:21 +0000 (13:58 +0200)
committerMarcin Siodelski <marcin@isc.org>
Wed, 22 Sep 2021 12:07:28 +0000 (14:07 +0200)
src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc
src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.cc

index 1b3a953a5f9bf8ceaa1ce43233a15767f0941a15..8648d97f295ed0e36555a4b49e65869b482d88aa 100644 (file)
@@ -319,17 +319,24 @@ TestConfigBackendDHCPv4::getAllOptionDefs4(const db::ServerSelector& server_sele
     OptionDefContainer option_defs;
     for (auto option_def : option_defs_) {
         bool got = false;
-        for (auto tag : tags) {
-            if (option_def->hasServerTag(ServerTag(tag))) {
+        if (server_selector.amUnassigned()) {
+            if (option_def->getServerTags().empty()) {
                 option_defs.push_back(option_def);
                 got = true;
-                break;
+            }
+        } else {
+            for (auto tag : tags) {
+                if (option_def->hasServerTag(ServerTag(tag))) {
+                    option_defs.push_back(option_def);
+                    got = true;
+                    break;
+                }
             }
         }
         if (got) {
             continue;
         }
-        if (option_def->hasAllServerTag()) {
+        if (option_def->hasAllServerTag() && !server_selector.amUnassigned()) {
             option_defs.push_back(option_def);
         }
     }
index 3afb48c6376763935dba543d549f4ac73dde8697..e59ad5dd668cef0ea5e3c3a2456be1022ae71028 100644 (file)
@@ -318,17 +318,24 @@ TestConfigBackendDHCPv6::getAllOptionDefs6(const db::ServerSelector& server_sele
     OptionDefContainer option_defs;
     for (auto option_def : option_defs_) {
         bool got = false;
-        for (auto tag : tags) {
-            if (option_def->hasServerTag(ServerTag(tag))) {
+        if (server_selector.amUnassigned()) {
+            if (option_def->getServerTags().empty()) {
                 option_defs.push_back(option_def);
                 got = true;
-                break;
+            }
+        } else {
+            for (auto tag : tags) {
+                if (option_def->hasServerTag(ServerTag(tag))) {
+                    option_defs.push_back(option_def);
+                    got = true;
+                    break;
+                }
             }
         }
         if (got) {
             continue;
         }
-        if (option_def->hasAllServerTag()) {
+        if (option_def->hasAllServerTag() && !server_selector.amUnassigned()) {
             option_defs.push_back(option_def);
         }
     }