Stop invalidating sudo timestamp on mode exit
This commit is contained in:
parent
026bbc4eff
commit
68a9696e7d
6 changed files with 55 additions and 43 deletions
|
|
@ -1,7 +1,7 @@
|
|||
"""Tests for application-level authorization flow."""
|
||||
|
||||
from contextlib import contextmanager
|
||||
from unittest.mock import Mock
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from textual.app import SuspendNotSupported
|
||||
|
||||
|
|
@ -125,3 +125,22 @@ class TestPrivilegedModeAuthorization:
|
|||
app.update_status.assert_called_once_with(
|
||||
"Interactive authorization requires terminal suspension; remaining in Read-only Mode."
|
||||
)
|
||||
|
||||
@patch("src.hosts.core.manager.subprocess.run")
|
||||
def test_leaving_privileged_mode_preserves_the_sudo_timestamp(self, mock_run):
|
||||
"""Test Ctrl+E clears app state without invalidating sudo globally."""
|
||||
app = HostsManagerApp()
|
||||
app.edit_mode = True
|
||||
app.manager.edit_mode = True
|
||||
app.manager.permission_manager.has_sudo = True
|
||||
app.manager.permission_manager._sudo_validated = True
|
||||
app.update_status = Mock()
|
||||
|
||||
app.action_toggle_edit_mode()
|
||||
|
||||
assert not app.edit_mode
|
||||
assert not app.manager.edit_mode
|
||||
assert not app.manager.permission_manager.has_sudo
|
||||
assert not app.manager.permission_manager._sudo_validated
|
||||
mock_run.assert_not_called()
|
||||
app.update_status.assert_called_once_with("Edit mode disabled")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue