Archived
This commit is contained in:
1 parent
aadc19341d
commit
3841e93e32
13 files changed
+73
-24
No files matched your search
@@ -0,0 +1,28 @@
|
||||
from app.core import audit, preferences
|
||||
|
||||
|
||||
def test_settings_are_loaded_in_batches(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(preferences, 'DATABASE_PATH', str(tmp_path / 'settings.db'))
|
||||
original = preferences._connect
|
||||
connections = []
|
||||
def connect():
|
||||
connections.append(1)
|
||||
return original()
|
||||
monkeypatch.setattr(preferences, '_connect', connect)
|
||||
assert preferences.get_preferences()['refresh_seconds'] == max(2, min(preferences.REFRESH_SECONDS, 60))
|
||||
assert len(connections) == 2
|
||||
connections.clear()
|
||||
assert preferences.get_branding()['name'] == 'WGTools-Extended'
|
||||
assert len(connections) == 2
|
||||
|
||||
|
||||
def test_historical_connection_lookup_uses_index(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(audit, 'DATABASE_PATH', str(tmp_path / 'audit.db'))
|
||||
audit.init_audit_database()
|
||||
with audit._connection() as conn:
|
||||
plan = conn.execute(
|
||||
"EXPLAIN QUERY PLAN SELECT created_at,details FROM audit_log "
|
||||
"WHERE action='wireguard.client_connected' AND object=? "
|
||||
"ORDER BY created_at DESC,id DESC LIMIT 1", ('wg0 · klient',)
|
||||
).fetchall()
|
||||
assert any('idx_audit_connection_lookup' in str(row[3]) for row in plan)
|
||||
Reference in new issue
Block a user