]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3727] fixed unittests
authorRazvan Becheriu <razvan@isc.org>
Sun, 26 Jan 2025 18:48:41 +0000 (20:48 +0200)
committerRazvan Becheriu <razvan@isc.org>
Mon, 27 Jan 2025 07:26:50 +0000 (09:26 +0200)
src/bin/dhcp4/dhcp4_messages.cc
src/bin/dhcp4/dhcp4_messages.mes
src/bin/dhcp6/dhcp6_messages.cc
src/bin/dhcp6/dhcp6_messages.mes
src/lib/dhcpsrv/tests/network_state_unittest.cc
src/share/api/status-get.json

index e9a0ef32e544a083ada4717d33d5c45246cb4a54..7a5f3be4a4d8219e1eed21959bc2167d80d9d628 100644 (file)
@@ -216,11 +216,11 @@ const char* values[] = {
     "DHCP4_CONFIG_SYNTAX_WARNING", "configuration syntax warning: %1",
     "DHCP4_CONFIG_UNRECOVERABLE_ERROR", "DHCPv4 server new configuration failed with an error which cannot be recovered",
     "DHCP4_CONFIG_UNSUPPORTED_OBJECT", "DHCPv4 server configuration includes an unsupported object: %1",
-    "DHCP4_DB_RECONNECT_DISABLED", "database reconnect is disabled: max-reconnect-tries %1, reconnect-wait-time %2",
-    "DHCP4_DB_RECONNECT_FAILED", "maximum number of database reconnect attempts: %1, has been exhausted without success",
-    "DHCP4_DB_RECONNECT_LOST_CONNECTION", "database connection lost.",
+    "DHCP4_DB_RECONNECT_DISABLED", "database reconnect is disabled: max-reconnect-tries %1, reconnect-wait-time %2, manager ID: %3, timer %4",
+    "DHCP4_DB_RECONNECT_FAILED", "maximum number of database reconnect attempts: %1, has been exhausted without success, manager ID: %2, timer %3",
+    "DHCP4_DB_RECONNECT_LOST_CONNECTION", "database connection lost: manager ID: %1, timer %2.",
     "DHCP4_DB_RECONNECT_NO_DB_CTL", "unexpected error in database reconnect",
-    "DHCP4_DB_RECONNECT_SUCCEEDED", "database connection recovered.",
+    "DHCP4_DB_RECONNECT_SUCCEEDED", "database connection recovered: manager ID: %1, timer %2.",
     "DHCP4_DDNS_REQUEST_SEND_FAILED", "failed sending a request to kea-dhcp-ddns, error: %1,  ncr: %2",
     "DHCP4_DECLINE_FAIL", "%1: error on decline lease for address %2: %3",
     "DHCP4_DECLINE_LEASE", "Received DHCPDECLINE for addr %1 from client %2. The lease will be unavailable for %3 seconds.",
index 08aa14a56c59ae2be002bad497f04d72232a35ac..c03d276e8e59343fddc095126050f7f3ea6e2914 100644 (file)
@@ -218,18 +218,18 @@ issued). Finally, the server could be restarted completely.
 This error message is issued when the configuration includes an unsupported
 object (i.e. a top level element).
 
-% DHCP4_DB_RECONNECT_DISABLED database reconnect is disabled: max-reconnect-tries %1, reconnect-wait-time %2
+% DHCP4_DB_RECONNECT_DISABLED database reconnect is disabled: max-reconnect-tries %1, reconnect-wait-time %2, manager ID: %3, timer %4
 This is an informational message indicating that connectivity to either the
 lease or host database or both and that automatic reconnect is not enabled.
 
-% DHCP4_DB_RECONNECT_FAILED maximum number of database reconnect attempts: %1, has been exhausted without success
+% DHCP4_DB_RECONNECT_FAILED maximum number of database reconnect attempts: %1, has been exhausted without success, manager ID: %2, timer %3
 This error indicates that the server failed to reconnect to the lease and/or
 host database(s) after making the maximum configured number of reconnect
 attempts. This might cause the server to shut down as specified in the
 configuration. Loss of connectivity is typically a network or database server
 issue.
 
-% DHCP4_DB_RECONNECT_LOST_CONNECTION database connection lost.
+% DHCP4_DB_RECONNECT_LOST_CONNECTION database connection lost: manager ID: %1, timer %2.
 This info message indicates that the connection has been lost and the dhcp
 service might have been disabled, as specified in the configuration, in order to
 try to recover the connection.
@@ -240,7 +240,7 @@ occur. It prohibits the server from attempting to reconnect to its
 databases if connectivity is lost, and the server exits. This error
 should be reported.
 
-% DHCP4_DB_RECONNECT_SUCCEEDED database connection recovered.
+% DHCP4_DB_RECONNECT_SUCCEEDED database connection recovered: manager ID: %1, timer %2.
 This info message indicates that the connection has been recovered and the dhcp
 service has been restored.
 
index 24cdc04676e80f7d9899752e64cb738fb6a77740..87a94715e0fa21447896de18d7e6e1d0665d1979 100644 (file)
@@ -200,11 +200,11 @@ const char* values[] = {
     "DHCP6_CONFIG_SYNTAX_WARNING", "configuration syntax warning: %1",
     "DHCP6_CONFIG_UNRECOVERABLE_ERROR", "DHCPv6 server new configuration failed with an error which cannot be recovered",
     "DHCP6_CONFIG_UNSUPPORTED_OBJECT", "DHCPv6 server configuration includes an unsupported object: %1",
-    "DHCP6_DB_RECONNECT_DISABLED", "database reconnect is disabled: max-reconnect-tries %1, reconnect-wait-time %2",
-    "DHCP6_DB_RECONNECT_FAILED", "maximum number of database reconnect attempts: %1, has been exhausted without success",
-    "DHCP6_DB_RECONNECT_LOST_CONNECTION", "database connection lost.",
+    "DHCP6_DB_RECONNECT_DISABLED", "database reconnect is disabled: max-reconnect-tries %1, reconnect-wait-time %2, manager ID: %3, timer %4",
+    "DHCP6_DB_RECONNECT_FAILED", "maximum number of database reconnect attempts: %1, has been exhausted without success, manager ID: %2, timer %3",
+    "DHCP6_DB_RECONNECT_LOST_CONNECTION", "database connection lost: manager ID: %1, timer %2.",
     "DHCP6_DB_RECONNECT_NO_DB_CTL", "unexpected error in database reconnect",
-    "DHCP6_DB_RECONNECT_SUCCEEDED", "database connection recovered.",
+    "DHCP6_DB_RECONNECT_SUCCEEDED", "database connection recovered: manager ID: %1, timer %2.",
     "DHCP6_DDNS_CREATE_ADD_NAME_CHANGE_REQUEST", "%1: created name change request: %2",
     "DHCP6_DDNS_FQDN_GENERATED", "%1: generated FQDN for the client: %2",
     "DHCP6_DDNS_GENERATED_FQDN_UPDATE_FAIL", "%1: failed to update the lease using address %2, after generating FQDN for a client, reason: %3",
index 37205de87f5fed0007ed72e3a3516e98d8aa6a32..562c2a89c10e35a10025d5b97daf859a5f03b426 100644 (file)
@@ -180,18 +180,18 @@ issued). Finally, the server could be restarted completely.
 This error message is issued when the configuration includes an unsupported
 object (i.e. a top level element).
 
-% DHCP6_DB_RECONNECT_DISABLED database reconnect is disabled: max-reconnect-tries %1, reconnect-wait-time %2
+% DHCP6_DB_RECONNECT_DISABLED database reconnect is disabled: max-reconnect-tries %1, reconnect-wait-time %2, manager ID: %3, timer %4
 This is an informational message indicating that connectivity to either the
 lease or host database or both and that automatic reconnect is not enabled.
 
-% DHCP6_DB_RECONNECT_FAILED maximum number of database reconnect attempts: %1, has been exhausted without success
+% DHCP6_DB_RECONNECT_FAILED maximum number of database reconnect attempts: %1, has been exhausted without success, manager ID: %2, timer %3
 This error indicates that the server failed to reconnect to the lease and/or
 host database(s) after making the maximum configured number of reconnect
 attempts. This might cause the server to shut down as specified in the
 configuration. Loss of connectivity is typically a network or database server
 issue.
 
-% DHCP6_DB_RECONNECT_LOST_CONNECTION database connection lost.
+% DHCP6_DB_RECONNECT_LOST_CONNECTION database connection lost: manager ID: %1, timer %2.
 This info message indicates that the connection has been lost and the dhcp
 service might have been disabled, as specified in the configuration, in order to
 try to recover the connection.
@@ -202,7 +202,7 @@ occur. It prohibits the server from attempting to reconnect to its
 databases if connectivity is lost, and the server exits. This error
 should be reported.
 
-% DHCP6_DB_RECONNECT_SUCCEEDED database connection recovered.
+% DHCP6_DB_RECONNECT_SUCCEEDED database connection recovered: manager ID: %1, timer %2.
 This info message indicates that the connection has been recovered and the dhcp
 service has been restored.
 
index 849ceb295acb8262198ab840264bcdeb7795b75e..3be9adb3c160145970588c04694a01f4f98c6adc 100644 (file)
@@ -70,12 +70,14 @@ public:
     // 4. Disable using 'HA remote command' origin 2 times (expect disabled state).
     // 5. Disable using 'HA remote command' origin 1 time different id (expect disabled state).
     // 6. Disable using 'DB connection' origin 2 times (expect disabled state).
-    // 7. Enable using 'user command' origin 1 time (expect disabled state).
-    // 8. Enable using 'HA local command' origin 1 time (expect disabled state).
-    // 9. Enable using 'HA local command' origin 1 time different id (expect disabled state).
-    // 10. Enable using 'HA remote command' origin 1 time (expect disabled state).
-    // 11. Enable using 'HA remote command' origin 1 time different id (expect disabled state).
-    // 12. Enable using 'DB connection' origin 2 times (expect enabled state).
+    // 7. Disable using 'DB connection' origin 1 time different id (expect disabled state).
+    // 8. Enable using 'user command' origin 1 time (expect disabled state).
+    // 9. Enable using 'HA local command' origin 1 time (expect disabled state).
+    // 10. Enable using 'HA local command' origin 1 time different id (expect disabled state).
+    // 11. Enable using 'HA remote command' origin 1 time (expect disabled state).
+    // 12. Enable using 'HA remote command' origin 1 time different id (expect disabled state).
+    // 13. Enable using 'DB connection' origin 1 times (expect disabled state).
+    // 14. Enable using 'DB connection' origin 1 time different id (expect disabled state).
     void disableEnableServiceUsingMultipleOriginsTest();
 
     /// @brief This test verifies that reset works, so that internal state is reset after
@@ -152,14 +154,32 @@ public:
 
     /// @brief This test verifies that reset works, so that internal state is reset after
     /// all managers are recreated.
-    /// 1. Disable using 'user command' origin 1 time (expect disabled state).
-    /// 2. Disable using 'HA command' origin 1 time (expect disabled state).
-    /// 3. Disable using 'DB connection' origin 3 time (expect disabled state).
-    /// 4. Reset using 'DB connection' origin (expect disabled state).
-    /// 5. Enable using 'user command' origin 1 time (expect disabled state).
-    /// 6. Enable using 'DB connection' origin 1 time (expect enabled state).
-    /// 7. Disable using 'DB connection' origin 3 times (expect disabled state).
-    /// 8. Reset using 'DB connection' origin (expect enabled state).
+    // 1. Disable using 'user command' origin 1 time (expect disabled state).
+    // 2. Disable using 'DB connection' origin 3 times with same id (expect disabled state).
+    // 3. Disable using 'HA remote command' origin 1 time (expect disabled state).
+    // 4. Disable using 'HA local command' origin 1 time (expect disabled state).
+    // 5. Enable using 'DB connection' origin (expect disabled state).
+    // 6. Enable using 'user command' origin 1 time (expect disabled state).
+    // 7. Enable using 'HA local command' origin 1 time (expect disabled state).
+    // 8. Enable using 'HA remote command' origin 1 time (expect enabled state).
+    // 9. Disable using 'user command' origin 1 time (expect disabled state).
+    // 10. Disable using 'DB connection' origin 3 times with different ids (expect disabled state).
+    // 11. Disable using 'HA remote command' origin 1 time (expect disabled state).
+    // 12. Disable using 'HA local command' origin 1 time (expect disabled state).
+    // 13. Enable using 'user command' origin 1 time (expect disabled state).
+    // 14. Enable using 'HA local command' origin 1 time (expect disabled state).
+    // 15. Enable using 'HA remote command' origin 1 time (expect disabled state).
+    // 16. Enable using 'DB connection' origin 3 times with different ids (expect enabled state).
+    // 17. Disable using 'user command' origin 1 time (expect disabled state).
+    // 18. Disable using 'DB connection' origin 3 times with different ids (expect disabled state).
+    // 19. Disable using 'HA remote command' origin 1 time (expect disabled state).
+    // 20. Disable using 'HA local command' origin 1 time (expect disabled state).
+    // 21. Enable using 'user command' origin 1 time (expect disabled state).
+    // 22. Enable using 'HA local command' origin 1 time (expect disabled state).
+    // 23. Enable using 'HA remote command' origin 1 time (expect disabled state).
+    // 24. Reset using 'DB connection' origin (expect enabled state).
+    // 25. Disable using 'DB connection' origin 3 times (expect disabled state).
+    // 26. Enable using 'DB connection' origin (expect enabled state).
     void resetUsingDBConnectionOriginTest();
 
     /// @brief This test verifies that it is possible to setup delayed execution of enableAll
@@ -190,22 +210,30 @@ public:
     ///
     /// @brief state The network state to check.
     /// @brief user Flag which indicates if user command disabled the state.
-    /// @brief db_connection Flag which indicates if db connection disabled the
-    /// state.
     /// @brief local The list of local IDs which disabled the state.
     /// @brief remote The list of remote IDs which disabled the state.
+    /// @brief db The list of manager IDs which disabled the state because of a
+    /// db connection failure.
     /// @brief global Flag which indicates if the state is disabled.
     void checkNetworkState(const NetworkState& state,
                            bool user,
-                           bool db_connection,
                            std::vector<uint32_t> local,
                            std::vector<uint32_t> remote,
+                           std::vector<uint32_t> db,
                            bool global) {
         std::ostringstream data;
-        data << std::boolalpha
-             << "{ \"disabled-by-db-connection\": " << db_connection
-             << ", \"disabled-by-local-command\": [ ";
+        data << std::boolalpha;
+        data << "{ \"disabled-by-db-connection\": [ ";
         bool not_first = false;
+        for (auto const value : db) {
+            if (not_first) {
+                data << ", ";
+            }
+            data << value;
+            not_first = true;
+        }
+        data << " ], \"disabled-by-local-command\": [ ";
+        not_first = false;
         for (auto const value : local) {
             if (not_first) {
                 data << ", ";
@@ -240,7 +268,7 @@ void
 NetworkStateTest::defaultTest() {
     NetworkState state;
 
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 }
 
 // This test verifies that it is possible to disable and then enable
@@ -251,19 +279,19 @@ NetworkStateTest::disableEnableServiceUsingUserCommandOriginTest() {
 
     // Test that enable/disable using 'user command' origin works
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.enableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 
     // Test that using 'user command' origin does not use internal counter
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.enableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
     state.enableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 }
 
 // This test verifies that it is possible to disable and then enable
@@ -274,33 +302,33 @@ NetworkStateTest::disableEnableServiceUsingHALocalCommandOriginTest() {
 
     // Test that enable/disable using 'HA local command' origin works
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, false, { 1000 }, {}, true);
+    checkNetworkState(state, false, { 1000 }, {}, {}, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 
     // Test that using 'HA local command' origin does not use internal counter
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, false, { 1000 }, {}, true);
+    checkNetworkState(state, false, { 1000 }, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, false, { 1000 }, {}, true);
+    checkNetworkState(state, false, { 1000 }, {}, {}, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
     state.enableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 
     // Test that using 'HA local command' origin does consider id
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, false, { 1000 }, {}, true);
+    checkNetworkState(state, false, { 1000 }, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND + 1);
-    checkNetworkState(state, false, false, { 1000, 1001 }, {}, true);
+    checkNetworkState(state, false, { 1000, 1001 }, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND + 2);
-    checkNetworkState(state, false, false, { 1000, 1001, 1002 }, {}, true);
+    checkNetworkState(state, false, { 1000, 1001, 1002 }, {}, {}, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, false, { 1001, 1002 }, {}, true);
+    checkNetworkState(state, false, { 1001, 1002 }, {}, {}, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND + 1);
-    checkNetworkState(state, false, false, { 1002 }, {}, true);
+    checkNetworkState(state, false, { 1002 }, {}, {}, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND + 2);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 }
 
 // This test verifies that it is possible to disable and then enable
@@ -311,33 +339,33 @@ NetworkStateTest::disableEnableServiceUsingHARemoteCommandOriginTest() {
 
     // Test that enable/disable using 'HA remote command' origin works
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, false, {}, { 2000 }, true);
+    checkNetworkState(state, false, {}, { 2000 }, {}, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 
     // Test that using 'HA remote command' origin does not use internal counter
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, false, {}, { 2000 }, true);
+    checkNetworkState(state, false, {}, { 2000 }, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, false, {}, { 2000 }, true);
+    checkNetworkState(state, false, {}, { 2000 }, {}, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
     state.enableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 
     // Test that using 'HA remote command' origin does consider id
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, false, {}, { 2000 }, true);
+    checkNetworkState(state, false, {}, { 2000 }, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND + 1);
-    checkNetworkState(state, false, false, {}, { 2000, 2001 }, true);
+    checkNetworkState(state, false, {}, { 2000, 2001 }, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND + 2);
-    checkNetworkState(state, false, false, {}, { 2000, 2001, 2002 }, true);
+    checkNetworkState(state, false, {}, { 2000, 2001, 2002 }, {}, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, false, {}, { 2001, 2002 }, true);
+    checkNetworkState(state, false, {}, { 2001, 2002 }, {}, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND + 1);
-    checkNetworkState(state, false, false, {}, { 2002 }, true);
+    checkNetworkState(state, false, {}, { 2002 }, {}, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND + 2);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 }
 
 // This test verifies that it is possible to disable and then enable
@@ -348,78 +376,92 @@ NetworkStateTest::disableEnableServiceUsingDBConnectionOriginTest() {
 
     // Test that enable/disable using 'DB connection' origin works
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, true, {}, {}, true);
+    checkNetworkState(state, false, {}, {}, { 3000 }, true);
     state.enableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 
-    // Test that using 'DB connection' origin uses internal counter
+    // Test that using 'DB connection' origin does not use internal counter
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, true, {}, {}, true);
+    checkNetworkState(state, false, {}, {}, { 3000 }, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, true, {}, {}, true);
+    checkNetworkState(state, false, {}, {}, { 3000 }, true);
     state.enableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, true, {}, {}, true);
+    checkNetworkState(state, false, {}, {}, {}, false);
     state.enableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
+
+    // Test that using 'DB connection' origin does consider id
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, true, {}, {}, true);
+    checkNetworkState(state, false, {}, {}, { 3000 }, true);
+    state.disableService(NetworkState::DB_CONNECTION + 1);
+    checkNetworkState(state, false, {}, {}, { 3000, 3001 }, true);
+    state.disableService(NetworkState::DB_CONNECTION + 2);
+    checkNetworkState(state, false, {}, {}, { 3000, 3001, 3002 }, true);
     state.enableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, { 3001, 3002 }, true);
+    state.enableService(NetworkState::DB_CONNECTION + 1);
+    checkNetworkState(state, false, {}, {}, { 3002 }, true);
+    state.enableService(NetworkState::DB_CONNECTION + 2);
+    checkNetworkState(state, false, {}, {}, {}, false);
 }
 
-// This test verifies that it is possible to disable and then enable
-// service using a combination of origins.
+/// @brief This test verifies that it is possible to disable and then enable
+/// service using a combination of origins.
 // 1. Disable using 'user command' origin 2 times (expect disabled state).
 // 2. Disable using 'HA local command' origin 2 times (expect disabled state).
 // 3. Disable using 'HA local command' origin 1 time different id (expect disabled state).
 // 4. Disable using 'HA remote command' origin 2 times (expect disabled state).
 // 5. Disable using 'HA remote command' origin 1 time different id (expect disabled state).
 // 6. Disable using 'DB connection' origin 2 times (expect disabled state).
-// 7. Enable using 'user command' origin 1 time (expect disabled state).
-// 8. Enable using 'HA local command' origin 1 time (expect disabled state).
-// 9. Enable using 'HA local command' origin 1 time different id (expect disabled state).
-// 10. Enable using 'HA remote command' origin 1 time (expect disabled state).
-// 11. Enable using 'HA remote command' origin 1 time different id (expect disabled state).
-// 12. Enable using 'DB connection' origin 2 times (expect enabled state).
+// 7. Disable using 'DB connection' origin 1 time different id (expect disabled state).
+// 8. Enable using 'user command' origin 1 time (expect disabled state).
+// 9. Enable using 'HA local command' origin 1 time (expect disabled state).
+// 10. Enable using 'HA local command' origin 1 time different id (expect disabled state).
+// 11. Enable using 'HA remote command' origin 1 time (expect disabled state).
+// 12. Enable using 'HA remote command' origin 1 time different id (expect disabled state).
+// 13. Enable using 'DB connection' origin 1 times (expect disabled state).
+// 14. Enable using 'DB connection' origin 1 time different id (expect disabled state).
 void
 NetworkStateTest::disableEnableServiceUsingMultipleOriginsTest() {
     NetworkState state;
 
     // Test that a combination properly affects the state
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, true, false, { 1000 }, {}, true);
+    checkNetworkState(state, true, { 1000 }, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, true, false, { 1000 }, {}, true);
+    checkNetworkState(state, true, { 1000 }, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND + 1);
-    checkNetworkState(state, true, false, { 1000, 1001 }, {}, true);
+    checkNetworkState(state, true, { 1000, 1001 }, {}, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, true, false, { 1000, 1001 }, { 2000 }, true);
+    checkNetworkState(state, true, { 1000, 1001 }, { 2000 }, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, true, false, { 1000, 1001 }, { 2000 }, true);
+    checkNetworkState(state, true, { 1000, 1001 }, { 2000 }, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND + 1);
-    checkNetworkState(state, true, false, { 1000, 1001 }, { 2000, 2001 }, true);
+    checkNetworkState(state, true, { 1000, 1001 }, { 2000, 2001 }, {}, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, true, true, { 1000, 1001 }, { 2000, 2001 }, true);
+    checkNetworkState(state, true, { 1000, 1001 }, { 2000, 2001 }, { 3000 }, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, true, true, { 1000, 1001 }, { 2000, 2001 }, true);
+    checkNetworkState(state, true, { 1000, 1001 }, { 2000, 2001 }, { 3000 }, true);
+    state.disableService(NetworkState::DB_CONNECTION + 1);
+    checkNetworkState(state, true, { 1000, 1001 }, { 2000, 2001 }, { 3000, 3001 }, true);
     state.enableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, false, true, { 1000, 1001 }, { 2000, 2001 }, true);
+    checkNetworkState(state, false, { 1000, 1001 }, { 2000, 2001 }, { 3000, 3001 }, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, true, { 1001 }, { 2000, 2001 }, true);
+    checkNetworkState(state, false, { 1001 }, { 2000, 2001 }, { 3000, 3001 }, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND + 1);
-    checkNetworkState(state, false, true, {}, { 2000, 2001 }, true);
+    checkNetworkState(state, false, {}, { 2000, 2001 }, { 3000, 3001 }, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, true, {}, { 2001 }, true);
+    checkNetworkState(state, false, {}, { 2001 }, { 3000, 3001 }, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND + 1);
-    checkNetworkState(state, false, true, {}, {}, true);
-    state.enableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, true, {}, {}, true);
+    checkNetworkState(state, false, {}, {}, { 3000, 3001 }, true);
     state.enableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, { 3001 },true);
+    state.enableService(NetworkState::DB_CONNECTION + 1);
+    checkNetworkState(state, false, {}, {}, {}, false);
 }
 
 // This test verifies that reset works, so that internal state is reset after
@@ -438,35 +480,35 @@ NetworkStateTest::resetUsingUserCommandOriginTest() {
 
     // Test User COMMAND + HA COMMAND + DB CONNECTION origins
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, true, false, { 1000 }, {}, true);
+    checkNetworkState(state, true, { 1000 }, {}, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, true, false, { 1000 }, { 2000 }, true);
+    checkNetworkState(state, true, { 1000 }, { 2000 }, {}, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, true, true, { 1000 }, { 2000 }, true);
+    checkNetworkState(state, true, { 1000 }, { 2000 }, { 3000 }, true);
     state.enableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, false, true, { 1000 }, { 2000 }, true);
+    checkNetworkState(state, false, { 1000 }, { 2000 }, { 3000 }, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, true, {}, { 2000 }, true);
+    checkNetworkState(state, false, {}, { 2000 }, { 3000 }, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, true, {}, {}, true);
+    checkNetworkState(state, false, {}, {}, { 3000 }, true);
     state.enableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 
     // Test User COMMAND origin only
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.enableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 }
 
 // This test verifies that reset works, so that internal state is reset after
@@ -501,85 +543,85 @@ void
 NetworkStateTest::resetUsingHALocalCommandOriginTest() {
     NetworkState state;
 
-    // Test HA LOCAL COMMAND + User COMMAND + DB CONNECTION origins
+    // Test HA COMMAND + User COMMAND + DB CONNECTION origins
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, true, false, { 1000 }, {}, true);
+    checkNetworkState(state, true, { 1000 }, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, true, false, { 1000 }, {}, true);
+    checkNetworkState(state, true, { 1000 }, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, true, false, { 1000 }, {}, true);
+    checkNetworkState(state, true, { 1000 }, {}, {}, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, true, true, { 1000 }, {}, true);
+    checkNetworkState(state, true, { 1000 }, {}, { 3000 }, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, true, true, { 1000 }, { 2000 }, true);
+    checkNetworkState(state, true, { 1000 }, { 2000 }, { 3000 }, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, true, true, {}, { 2000 }, true);
+    checkNetworkState(state, true, {}, { 2000 }, { 3000 }, true);
     state.enableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, false, true, {}, { 2000 }, true);
+    checkNetworkState(state, false, {}, { 2000 }, { 3000 }, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, true, {}, {}, true);
+    checkNetworkState(state, false, {}, {}, { 3000 }, true);
     state.enableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 
-    // Test HA LOCAL COMMAND + User COMMAND + DB CONNECTION origins
+    // Test HA COMMAND + User COMMAND + DB CONNECTION origins
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, true, false, { 1000 }, {}, true);
+    checkNetworkState(state, true, { 1000 }, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND + 1);
-    checkNetworkState(state, true, false, { 1000, 1001 }, {}, true);
+    checkNetworkState(state, true, { 1000, 1001 }, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND + 2);
-    checkNetworkState(state, true, false, { 1000, 1001, 1002 }, {}, true);
+    checkNetworkState(state, true, { 1000, 1001, 1002 }, {}, {}, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, true, true, { 1000, 1001, 1002 }, {}, true);
+    checkNetworkState(state, true, { 1000, 1001, 1002 }, {}, { 3000 }, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, true, true, { 1000, 1001, 1002 }, { 2000 }, true);
+    checkNetworkState(state, true, { 1000, 1001, 1002 }, { 2000 }, { 3000 }, true);
     state.enableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, false, true, { 1000, 1001, 1002 }, { 2000 }, true);
+    checkNetworkState(state, false, { 1000, 1001, 1002 }, { 2000 }, { 3000 }, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, true, { 1000, 1001, 1002 }, {}, true);
+    checkNetworkState(state, false, { 1000, 1001, 1002 }, {}, { 3000 }, true);
     state.enableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, false, { 1000, 1001, 1002 }, {}, true);
+    checkNetworkState(state, false, { 1000, 1001, 1002 }, {}, {}, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, false, { 1001, 1002 }, {}, true);
+    checkNetworkState(state, false, { 1001, 1002 }, {}, {}, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND + 1);
-    checkNetworkState(state, false, false, { 1002 }, {}, true);
+    checkNetworkState(state, false, { 1002 }, {}, {}, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND + 2);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 
-    // Test HA LOCAL COMMAND + User COMMAND + DB CONNECTION origins
+    // Test HA COMMAND + User COMMAND + DB CONNECTION origins
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, true, false, { 1000 }, {}, true);
+    checkNetworkState(state, true, { 1000 }, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND + 1);
-    checkNetworkState(state, true, false, { 1000, 1001 }, {}, true);
+    checkNetworkState(state, true, { 1000, 1001 }, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND + 2);
-    checkNetworkState(state, true, false, { 1000, 1001, 1002 }, {}, true);
+    checkNetworkState(state, true, { 1000, 1001, 1002 }, {}, {}, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, true, true, { 1000, 1001, 1002 }, {}, true);
+    checkNetworkState(state, true, { 1000, 1001, 1002 }, {}, { 3000 }, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, true, true, { 1000, 1001, 1002 }, { 2000 }, true);
+    checkNetworkState(state, true, { 1000, 1001, 1002 }, { 2000 }, { 3000 }, true);
     state.enableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, false, true, { 1000, 1001, 1002 }, { 2000 }, true);
+    checkNetworkState(state, false, { 1000, 1001, 1002 }, { 2000 }, { 3000 }, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, true, { 1000, 1001, 1002 }, {}, true);
+    checkNetworkState(state, false, { 1000, 1001, 1002 }, {}, { 3000 }, true);
     state.enableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, false, { 1000, 1001, 1002 }, {}, true);
+    checkNetworkState(state, false, { 1000, 1001, 1002 }, {}, {}, true);
     state.resetForLocalCommands();
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 
     // Test HA LOCAL COMMAND origin only
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, false, { 1000 }, {}, true);
+    checkNetworkState(state, false, { 1000 }, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, false, { 1000 }, {}, true);
+    checkNetworkState(state, false, { 1000 }, {}, {}, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, false, { 1000 }, {}, true);
+    checkNetworkState(state, false, { 1000 }, {}, {}, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 }
 
 // This test verifies that reset works, so that internal state is reset after
@@ -614,132 +656,198 @@ void
 NetworkStateTest::resetUsingHARemoteCommandOriginTest() {
     NetworkState state;
 
-    // Test HA REMOTE COMMAND + User COMMAND + DB CONNECTION origins
+    // Test HA COMMAND + User COMMAND + DB CONNECTION origins
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, true, false, {}, { 2000 }, true);
+    checkNetworkState(state, true, {}, { 2000 }, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, true, false, {}, { 2000 }, true);
+    checkNetworkState(state, true, {}, { 2000 }, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, true, false, {}, { 2000 }, true);
+    checkNetworkState(state, true, {}, { 2000 }, {}, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, true, true, {}, { 2000 }, true);
+    checkNetworkState(state, true, {}, { 2000 }, { 3000 }, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, true, true, { 1000 }, { 2000 }, true);
+    checkNetworkState(state, true, { 1000 }, { 2000 }, { 3000 }, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, true, true, { 1000 }, {}, true);
+    checkNetworkState(state, true, { 1000 }, {}, { 3000 }, true);
     state.enableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, false, true, { 1000 }, {}, true);
+    checkNetworkState(state, false, { 1000 }, {}, { 3000 }, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, true, {}, {}, true);
+    checkNetworkState(state, false, {}, {}, { 3000 }, true);
     state.enableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 
-    // Test HA REMOTE COMMAND + User COMMAND + DB CONNECTION origins
+    // Test HA COMMAND + User COMMAND + DB CONNECTION origins
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, true, false, {}, { 2000 }, true);
+    checkNetworkState(state, true, {}, { 2000 }, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND + 1);
-    checkNetworkState(state, true, false, {}, { 2000, 2001 }, true);
+    checkNetworkState(state, true, {}, { 2000, 2001 }, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND + 2);
-    checkNetworkState(state, true, false, {}, { 2000, 2001, 2002 }, true);
+    checkNetworkState(state, true, {}, { 2000, 2001, 2002 }, {}, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, true, true, {}, { 2000, 2001, 2002 }, true);
+    checkNetworkState(state, true, {}, { 2000, 2001, 2002 }, { 3000 }, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, true, true, { 1000 }, { 2000, 2001, 2002 }, true);
+    checkNetworkState(state, true, { 1000 }, { 2000, 2001, 2002 }, { 3000 }, true);
     state.enableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, false, true, { 1000 }, { 2000, 2001, 2002 }, true);
+    checkNetworkState(state, false, { 1000 }, { 2000, 2001, 2002 }, { 3000 }, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, true, {}, { 2000, 2001, 2002 }, true);
+    checkNetworkState(state, false, {}, { 2000, 2001, 2002 }, { 3000 }, true);
     state.enableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, false, {}, { 2000, 2001, 2002 }, true);
+    checkNetworkState(state, false, {}, { 2000, 2001, 2002 }, {}, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, false, {}, { 2001, 2002 }, true);
+    checkNetworkState(state, false, {}, { 2001, 2002 }, {}, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND + 1);
-    checkNetworkState(state, false, false, {}, { 2002}, true);
+    checkNetworkState(state, false, {}, { 2002 }, {}, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND + 2);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 
-    // Test HA REMOTE COMMAND + User COMMAND + DB CONNECTION origins
+    // Test HA COMMAND + User COMMAND + DB CONNECTION origins
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, true, false, {}, { 2000 }, true);
+    checkNetworkState(state, true, {}, { 2000 }, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND + 1);
-    checkNetworkState(state, true, false, {}, { 2000, 2001 }, true);
+    checkNetworkState(state, true, {}, { 2000, 2001 }, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND + 2);
-    checkNetworkState(state, true, false, {}, { 2000, 2001, 2002 }, true);
+    checkNetworkState(state, true, {}, { 2000, 2001, 2002 }, {}, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, true, true, {}, { 2000, 2001, 2002 }, true);
+    checkNetworkState(state, true, {}, { 2000, 2001, 2002 }, { 3000 }, true);
     state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, true, true, { 1000 }, { 2000, 2001, 2002 }, true);
+    checkNetworkState(state, true, { 1000 }, { 2000, 2001, 2002 }, { 3000 }, true);
     state.enableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, false, true, { 1000 }, { 2000, 2001, 2002 }, true);
+    checkNetworkState(state, false, { 1000 }, { 2000, 2001, 2002 }, { 3000 }, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, true, {}, { 2000, 2001, 2002 }, true);
+    checkNetworkState(state, false, {}, { 2000, 2001, 2002 }, { 3000 }, true);
     state.enableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, false, {}, { 2000, 2001, 2002 }, true);
+    checkNetworkState(state, false, {}, { 2000, 2001, 2002 }, {}, true);
     state.resetForRemoteCommands();
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 
-    // Test HA RELOTE COMMAND origin only
+    // Test HA REMOTE COMMAND origin only
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, false, {}, { 2000 }, true);
+    checkNetworkState(state, false, {}, { 2000 }, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, false, {}, { 2000 }, true);
+    checkNetworkState(state, false, {}, { 2000 }, {}, true);
     state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, false, {}, { 2000 }, true);
+    checkNetworkState(state, false, {}, { 2000 }, {}, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, {}, false);
 }
 
-// This test verifies that reset works, so that internal state is  reset after
-// all managers are recreated.
+/// @brief This test verifies that reset works, so that internal state is reset after
+/// all managers are recreated.
 // 1. Disable using 'user command' origin 1 time (expect disabled state).
-// 2. Disable using 'HA command' origin 1 time (expect disabled state).
-// 3. Disable using 'DB connection' origin 3 time (expect disabled state).
-// 4. Reset using 'DB connection' origin (expect disabled state).
-// 5. Enable using 'user command' origin 1 time (expect disabled state).
-// 6. Enable using 'DB connection' origin 1 time (expect enabled state).
-// 7. Disable using 'DB connection' origin 3 times (expect disabled state).
-// 8. Reset using 'DB connection' origin (expect enabled state).
+// 2. Disable using 'DB connection' origin 3 times with same id (expect disabled state).
+// 3. Disable using 'HA remote command' origin 1 time (expect disabled state).
+// 4. Disable using 'HA local command' origin 1 time (expect disabled state).
+// 5. Enable using 'DB connection' origin (expect disabled state).
+// 6. Enable using 'user command' origin 1 time (expect disabled state).
+// 7. Enable using 'HA local command' origin 1 time (expect disabled state).
+// 8. Enable using 'HA remote command' origin 1 time (expect enabled state).
+// 9. Disable using 'user command' origin 1 time (expect disabled state).
+// 10. Disable using 'DB connection' origin 3 times with different ids (expect disabled state).
+// 11. Disable using 'HA remote command' origin 1 time (expect disabled state).
+// 12. Disable using 'HA local command' origin 1 time (expect disabled state).
+// 13. Enable using 'user command' origin 1 time (expect disabled state).
+// 14. Enable using 'HA local command' origin 1 time (expect disabled state).
+// 15. Enable using 'HA remote command' origin 1 time (expect disabled state).
+// 16. Enable using 'DB connection' origin 3 times with different ids (expect enabled state).
+// 17. Disable using 'user command' origin 1 time (expect disabled state).
+// 18. Disable using 'DB connection' origin 3 times with different ids (expect disabled state).
+// 19. Disable using 'HA remote command' origin 1 time (expect disabled state).
+// 20. Disable using 'HA local command' origin 1 time (expect disabled state).
+// 21. Enable using 'user command' origin 1 time (expect disabled state).
+// 22. Enable using 'HA local command' origin 1 time (expect disabled state).
+// 23. Enable using 'HA remote command' origin 1 time (expect disabled state).
+// 24. Reset using 'DB connection' origin (expect enabled state).
+// 25. Disable using 'DB connection' origin 3 times (expect disabled state).
+// 26. Enable using 'DB connection' origin (expect enabled state).
 void
 NetworkStateTest::resetUsingDBConnectionOriginTest() {
     NetworkState state;
 
-    // Test DB CONNECTION + User COMMAND + HA COMMAND origins
+    // Test HA COMMAND + User COMMAND + DB CONNECTION origins
     state.disableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, true, false, {}, {}, true);
-    state.disableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, true, false, { 1000 }, {}, true);
-    state.disableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, true, false, { 1000 }, { 2000 }, true);
+    checkNetworkState(state, true, {}, {}, {}, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, true, true, { 1000 }, { 2000 }, true);
+    checkNetworkState(state, true, {}, {}, { 3000 }, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, true, true, { 1000 }, { 2000 }, true);
+    checkNetworkState(state, true, {}, {}, { 3000 }, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, true, true, { 1000 }, { 2000 }, true);
-    state.resetForDbConnection();
-    checkNetworkState(state, true, false, { 1000 }, { 2000 }, true);
+    checkNetworkState(state, true, {}, {}, { 3000 }, true);
+    state.disableService(NetworkState::HA_REMOTE_COMMAND);
+    checkNetworkState(state, true, {}, { 2000 }, { 3000 }, true);
+    state.disableService(NetworkState::HA_LOCAL_COMMAND);
+    checkNetworkState(state, true, { 1000 }, { 2000 }, { 3000 }, true);
+    state.enableService(NetworkState::DB_CONNECTION);
+    checkNetworkState(state, true, { 1000 }, { 2000 }, {}, true);
+    state.enableService(NetworkState::USER_COMMAND);
+    checkNetworkState(state, false, { 1000 }, { 2000 }, {}, true);
+    state.enableService(NetworkState::HA_LOCAL_COMMAND);
+    checkNetworkState(state, false, {}, { 2000 }, {}, true);
+    state.enableService(NetworkState::HA_REMOTE_COMMAND);
+    checkNetworkState(state, false, {}, {}, {}, false);
+
+    // Test HA COMMAND + User COMMAND + DB CONNECTION origins
+    state.disableService(NetworkState::USER_COMMAND);
+    checkNetworkState(state, true, {}, {}, {}, true);
+    state.disableService(NetworkState::DB_CONNECTION);
+    checkNetworkState(state, true, {}, {}, { 3000 }, true);
+    state.disableService(NetworkState::DB_CONNECTION + 1);
+    checkNetworkState(state, true, {}, {}, { 3000, 3001 }, true);
+    state.disableService(NetworkState::DB_CONNECTION + 2);
+    checkNetworkState(state, true, {}, {}, { 3000, 3001, 3002 }, true);
+    state.disableService(NetworkState::HA_REMOTE_COMMAND);
+    checkNetworkState(state, true, {}, { 2000 }, { 3000, 3001, 3002 }, true);
+    state.disableService(NetworkState::HA_LOCAL_COMMAND);
+    checkNetworkState(state, true, { 1000 }, { 2000 }, { 3000, 3001, 3002 }, true);
+    state.enableService(NetworkState::USER_COMMAND);
+    checkNetworkState(state, false, { 1000 }, { 2000 }, { 3000, 3001, 3002 }, true);
+    state.enableService(NetworkState::HA_LOCAL_COMMAND);
+    checkNetworkState(state, false, {}, { 2000 }, { 3000, 3001, 3002 }, true);
+    state.enableService(NetworkState::HA_REMOTE_COMMAND);
+    checkNetworkState(state, false, {}, {}, { 3000, 3001, 3002 }, true);
+    state.enableService(NetworkState::DB_CONNECTION);
+    checkNetworkState(state, false, {}, {}, { 3001, 3002 }, true);
+    state.enableService(NetworkState::DB_CONNECTION + 1);
+    checkNetworkState(state, false, {}, {}, { 3002 }, true);
+    state.enableService(NetworkState::DB_CONNECTION + 2);
+    checkNetworkState(state, false, {}, {}, {}, false);
+
+    // Test HA COMMAND + User COMMAND + DB CONNECTION origins
+    state.disableService(NetworkState::USER_COMMAND);
+    checkNetworkState(state, true, {}, {}, {}, true);
+    state.disableService(NetworkState::DB_CONNECTION);
+    checkNetworkState(state, true, {}, {}, { 3000 }, true);
+    state.disableService(NetworkState::DB_CONNECTION + 1);
+    checkNetworkState(state, true, {}, {}, { 3000, 3001 }, true);
+    state.disableService(NetworkState::DB_CONNECTION + 2);
+    checkNetworkState(state, true, {}, {}, { 3000, 3001, 3002 }, true);
+    state.disableService(NetworkState::HA_REMOTE_COMMAND);
+    checkNetworkState(state, true, {}, { 2000 }, { 3000, 3001, 3002 }, true);
+    state.disableService(NetworkState::HA_LOCAL_COMMAND);
+    checkNetworkState(state, true, { 1000 }, { 2000 }, { 3000, 3001, 3002 }, true);
     state.enableService(NetworkState::USER_COMMAND);
-    checkNetworkState(state, false, false, { 1000 }, { 2000 }, true);
+    checkNetworkState(state, false, { 1000 }, { 2000 }, { 3000, 3001, 3002 }, true);
     state.enableService(NetworkState::HA_LOCAL_COMMAND);
-    checkNetworkState(state, false, false, {}, { 2000 }, true);
+    checkNetworkState(state, false, {}, { 2000 }, { 3000, 3001, 3002 }, true);
     state.enableService(NetworkState::HA_REMOTE_COMMAND);
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, { 3000, 3001, 3002 }, true);
+    state.resetForDbConnection();
+    checkNetworkState(state, false, {}, {}, {}, false);
 
     // Test DB CONNECTION origin only
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, true, {}, {}, true);
+    checkNetworkState(state, false, {}, {}, { 3000 }, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, true, {}, {}, true);
+    checkNetworkState(state, false, {}, {}, { 3000 }, true);
     state.disableService(NetworkState::DB_CONNECTION);
-    checkNetworkState(state, false, true, {}, {}, true);
-    state.resetForDbConnection();
-    checkNetworkState(state, false, false, {}, {}, false);
+    checkNetworkState(state, false, {}, {}, { 3000 }, true);
+    state.enableService(NetworkState::DB_CONNECTION);
+    checkNetworkState(state, false, {}, {}, {}, false);
 }
 
 // This test verifies that it is possible to setup delayed execution of enableAll
index 18550205a526ee6d524a4d9b5ff12d33dbfc7d95..caca9e38c043ec728b6216b9a5b47f17f9c0b7fd 100644 (file)
@@ -20,9 +20,9 @@
         "    \"result\": <integer>,",
         "    \"arguments\": {",
         "        \"dhcp-state\": {",
+        "            \"disabled-by-db-connection\": [],",
         "            \"disabled-by-local-command\": [],",
         "            \"disabled-by-remote-command\": [],",
-        "            \"disabled-by-db-connection\": [],",
         "            \"disabled-by-user\": false,",
         "            \"globally-disabled\": false",
         "        },",