@@ -65,41 +65,4 @@ class APIModelsRESTAPISettingsSyncTestCase extends TestCase {
6565 $ this ->assert_equals ($ original_api_config , $ new_api_config );
6666 $ this ->assert_not_equals ($ sync_api_config , $ new_api_config );
6767 }
68-
69- /**
70- * Checks that the 'sync()' method correctly syncs the API config to HA peers.
71- */
72- public function test_sync (): void {
73- # Use a non-pfSense host as an HA peer
74- $ api_settings = new RESTAPISettings ();
75- $ api_settings ->ha_sync ->value = true ;
76- $ api_settings ->ha_sync_hosts ->value = ['www.example.com ' ];
77- $ api_settings ->ha_sync_username ->value = 'admin ' ;
78- $ api_settings ->ha_sync_password ->value = 'pfsense ' ;
79- $ api_settings ->update ();
80-
81- # Read the syslog and ensure the synced failed
82- # TODO: This test is flaky and needs to be reworked
83- // RESTAPISettingsSync::sync();
84- // $syslog = file_get_contents('/var/log/system.log');
85- // $this->assert_str_contains(
86- // $syslog,
87- // 'Failed to sync REST API settings to example.com: received unexpected response.',
88- // );
89-
90- # Use a non-existent host as an HA peer and ensure the sync failed
91- $ api_settings ->ha_sync_hosts ->value = ['127.1.2.3 ' ];
92- $ api_settings ->update ();
93- RESTAPISettingsSync::sync ();
94- $ syslog = file_get_contents ('/var/log/system.log ' );
95- $ this ->assert_str_contains ($ syslog , 'Failed to sync REST API settings to 127.1.2.3: no response received. ' );
96-
97- # Use bad credentials and ensure the sync failed
98- $ api_settings ->ha_sync_hosts ->value = ['127.0.0.1 ' ];
99- $ api_settings ->ha_sync_password ->value = 'bad password ' ;
100- $ api_settings ->update ();
101- RESTAPISettingsSync::sync ();
102- $ syslog = file_get_contents ('/var/log/system.log ' );
103- $ this ->assert_str_contains ($ syslog , 'Failed to sync REST API settings to 127.0.0.1: Authentication failed ' );
104- }
10568}
0 commit comments