Enhance HostsManager to prevent modification and movement of default system entries; add is_default_entry method to HostEntry and update sorting methods to prioritize default entries.

This commit is contained in:
Philip Henning 2025-07-29 23:04:29 +02:00
parent 8c1cd2047e
commit 3084650c27
6 changed files with 122 additions and 45 deletions

View file

@ -326,9 +326,9 @@ class TestHostsManagerApp:
app.action_sort_by_ip()
# Check that entries are sorted
assert app.hosts_file.entries[0].ip_address == "10.0.0.1"
assert app.hosts_file.entries[1].ip_address == "127.0.0.1"
# Check that entries are sorted with default entries on top
assert app.hosts_file.entries[0].ip_address == "127.0.0.1" # Default entry first
assert app.hosts_file.entries[1].ip_address == "10.0.0.1" # Then sorted non-defaults
assert app.hosts_file.entries[2].ip_address == "192.168.1.1"
assert app.sort_column == "ip"