#2706 - Additional assert on new test and a guard clause on LocalTerminalConnection.execute() to check that the Terminal service is running before sending a command
This commit is contained in:
@@ -84,8 +84,11 @@ class LocalTerminalConnection(TerminalClientConnection):
|
|||||||
|
|
||||||
ip_address: str = "Local Connection"
|
ip_address: str = "Local Connection"
|
||||||
|
|
||||||
def execute(self, command: Any) -> RequestResponse:
|
def execute(self, command: Any) -> Optional[RequestResponse]:
|
||||||
"""Execute a given command on local Terminal."""
|
"""Execute a given command on local Terminal."""
|
||||||
|
if self.parent_terminal.operating_state != ServiceOperatingState.RUNNING:
|
||||||
|
self.parent_terminal.sys_log.warning("Cannot process command as system not running")
|
||||||
|
return None
|
||||||
if not self.is_active:
|
if not self.is_active:
|
||||||
self.parent_terminal.sys_log.warning("Connection inactive, cannot execute")
|
self.parent_terminal.sys_log.warning("Connection inactive, cannot execute")
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -376,3 +376,5 @@ def test_terminal_rejects_commands_if_disconnect(basic_network):
|
|||||||
assert remote_connection.execute(["software_manager", "application", "install", "RansomwareScript"]) is False
|
assert remote_connection.execute(["software_manager", "application", "install", "RansomwareScript"]) is False
|
||||||
|
|
||||||
assert not computer_b.software_manager.software.get("RansomwareScript")
|
assert not computer_b.software_manager.software.get("RansomwareScript")
|
||||||
|
|
||||||
|
assert remote_connection.is_active is False
|
||||||
|
|||||||
Reference in New Issue
Block a user