From 155562cb683fa6216eae02598528e2662f8ce0f7 Mon Sep 17 00:00:00 2001 From: Charlie Crane Date: Fri, 19 Jul 2024 11:18:17 +0100 Subject: [PATCH] #2712 - Commit before merging in changes on dev --- src/primaite/simulator/network/protocols/ssh.py | 3 ++- .../simulator/system/services/terminal/terminal.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/primaite/simulator/network/protocols/ssh.py b/src/primaite/simulator/network/protocols/ssh.py index 86544813..af1c550a 100644 --- a/src/primaite/simulator/network/protocols/ssh.py +++ b/src/primaite/simulator/network/protocols/ssh.py @@ -56,6 +56,7 @@ class SSHConnectionMessage(IntEnum): SSH_MSG_CHANNEL_CLOSE = 87 """Closes the channel.""" + class SSHUserCredentials(DataPacket): """Hold Username and Password in SSH Packets""" @@ -77,4 +78,4 @@ class SSHPacket(DataPacket): ssh_output: Optional[RequestResponse] = None # The Request Manager's returned RequestResponse - ssh_command: Optional[str] = None # This is the request string \ No newline at end of file + ssh_command: Optional[str] = None # This is the request string diff --git a/src/primaite/simulator/system/services/terminal/terminal.py b/src/primaite/simulator/system/services/terminal/terminal.py index 3cf9fc0d..9dd40edc 100644 --- a/src/primaite/simulator/system/services/terminal/terminal.py +++ b/src/primaite/simulator/system/services/terminal/terminal.py @@ -100,7 +100,12 @@ class Terminal(Service): _login_valid = Terminal._LoginValidator(terminal=self) rm = super()._init_request_manager() - rm.add_request("login", request_type=RequestType(func=lambda request, context: RequestResponse.from_bool(self._validate_login()), validator=_login_valid)) + rm.add_request( + "login", + request_type=RequestType( + func=lambda request, context: RequestResponse.from_bool(self._validate_login()), validator=_login_valid + ), + ) return rm def _validate_login(self, user_account: Optional[str]) -> bool: @@ -127,12 +132,11 @@ class Terminal(Service): def __call__(self, request: RequestFormat, context: Dict) -> bool: """Return whether the Terminal has valid login credentials""" return self.terminal.login_status - + @property def fail_message(self) -> str: """Message that is reported when a request is rejected by this validator""" - return ("Cannot perform request on terminal as not logged in.") - + return "Cannot perform request on terminal as not logged in." # %% Inbound