windows installer fixes
This commit is contained in:
+35
-2
@@ -435,10 +435,43 @@ class TestServerComponent(unittest.TestCase):
|
||||
self.assertEqual(Server.format_relative_time(None), "Never")
|
||||
self.assertEqual(Server.format_relative_time(""), "Never")
|
||||
self.assertEqual(Server.format_relative_time("invalid-date-string"), "invalid-date-str")
|
||||
just_now = now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
self.assertIn(Server.format_relative_time(just_now), ("0s ago", "1s ago", "Just now"))
|
||||
now_fresh = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S")
|
||||
rel = Server.format_relative_time(now_fresh)
|
||||
self.assertTrue(rel.endswith("s ago") or rel == "Just now", f"Unexpected relative time: {rel}")
|
||||
|
||||
def test_integrated_local_log_collector_zero_seats(self):
|
||||
"""Tests that local hub log collection runs without license, registering a 0-seat built-in client."""
|
||||
Server.init_db(self.test_db, enrollment_secret="test-sec-456", max_seats=0)
|
||||
Server.SERVER_STATE["config"] = {
|
||||
"db_path": self.test_db,
|
||||
"evaluation_window_hours": 12,
|
||||
"min_persistence_runs": 1
|
||||
}
|
||||
|
||||
# Run cycle
|
||||
state = {}
|
||||
processed = Server.run_local_log_collection_cycle(self.test_db, window_hours=12, min_runs=1, state=state)
|
||||
|
||||
# Verify local hub client entry exists in clients table
|
||||
machine_id = Server.get_machine_identifier()
|
||||
conn = sqlite3.connect(self.test_db)
|
||||
c = conn.cursor()
|
||||
c.execute("SELECT client_id, cert_fingerprint, status FROM clients WHERE client_id = ?", (machine_id,))
|
||||
row = c.fetchone()
|
||||
conn.close()
|
||||
|
||||
self.assertIsNotNone(row)
|
||||
self.assertEqual(row[0], machine_id)
|
||||
self.assertEqual(row[1], "LOCAL-HOST-BUILTIN")
|
||||
self.assertEqual(row[2], "active")
|
||||
|
||||
# Verify active seat count is STILL 0 (exempt from seat accounting)
|
||||
client_data = Server.list_clients()
|
||||
self.assertEqual(client_data["active_seats"], 0)
|
||||
self.assertEqual(len(client_data["clients"]), 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user