#2706 - Commented out references to UserSessionManager to remove the dependency.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
"source": [
|
||||
"This notebook serves as a guide on the functionality and use of the new Terminal simulation component.\n",
|
||||
"\n",
|
||||
"By default, the Terminal will come pre-installed on any simulation component which inherits from `HostNode`, and simulates the Secure Shell (SSH) protocol as the communication method."
|
||||
"By default, the Terminal will come pre-installed on any simulation component which inherits from `HostNode` (Computer, Server, Printer), and simulates the Secure Shell (SSH) protocol as the communication method."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -131,6 +131,13 @@
|
||||
"\n",
|
||||
"computer_b.file_system.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"The resultant call to `computer_b.file_system.show()` shows that the new folder has been created."
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from ipaddress import IPv4Address
|
||||
from typing import Any, Dict, List, Optional
|
||||
from uuid import uuid4
|
||||
|
||||
from prettytable import MARKDOWN, PrettyTable
|
||||
from pydantic import BaseModel
|
||||
@@ -88,10 +89,6 @@ class Terminal(Service):
|
||||
state = super().describe_state()
|
||||
return state
|
||||
|
||||
def apply_request(self, request: List[str | int | float | Dict], context: Dict | None = None) -> RequestResponse:
|
||||
"""Apply Terminal Request."""
|
||||
return super().apply_request(request, context)
|
||||
|
||||
def show(self, markdown: bool = False):
|
||||
"""
|
||||
Display the remote connections to this terminal instance in tabular format.
|
||||
@@ -141,7 +138,8 @@ class Terminal(Service):
|
||||
|
||||
def _logoff() -> RequestResponse:
|
||||
"""Logoff from connection."""
|
||||
self.parent.UserSessionManager.logoff(self.connection_uuid)
|
||||
# TODO: Uncomment this when UserSessionManager merged.
|
||||
# self.parent.UserSessionManager.logoff(self.connection_uuid)
|
||||
self.disconnect(self.connection_uuid)
|
||||
|
||||
return RequestResponse(status="success", data={})
|
||||
@@ -204,7 +202,9 @@ class Terminal(Service):
|
||||
|
||||
def _process_local_login(self, username: str, password: str) -> bool:
|
||||
"""Local session login to terminal."""
|
||||
self.connection_uuid = self.parent.UserSessionManager.login(username=username, password=password)
|
||||
# TODO: Un-comment this when UserSessionManager is merged.
|
||||
# self.connection_uuid = self.parent.UserSessionManager.login(username=username, password=password)
|
||||
self.connection_uuid = str(uuid4())
|
||||
self.is_connected = True
|
||||
if self.connection_uuid:
|
||||
self.sys_log.info(f"Login request authorised, connection uuid: {self.connection_uuid}")
|
||||
@@ -239,7 +239,9 @@ class Terminal(Service):
|
||||
username: str = payload.user_account.username
|
||||
password: str = payload.user_account.password
|
||||
self.sys_log.info(f"Sending UserAuth request to UserSessionManager, username={username}, password={password}")
|
||||
connection_uuid = self.parent.UserSessionManager.remote_login(username=username, password=password)
|
||||
# TODO: Un-comment this when UserSessionManager is merged.
|
||||
# connection_uuid = self.parent.UserSessionManager.remote_login(username=username, password=password)
|
||||
connection_uuid = str(uuid4())
|
||||
self.is_connected = True
|
||||
if connection_uuid:
|
||||
# Send uuid to remote
|
||||
|
||||
@@ -45,6 +45,17 @@ def basic_network() -> Network:
|
||||
return network
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def game_and_agent_fixture(game_and_agent):
|
||||
"""Create a game with a simple agent that can be controlled by the tests."""
|
||||
game, agent = game_and_agent
|
||||
|
||||
client_1: Computer = game.simulation.network.get_node_by_hostname("client_1")
|
||||
client_1.start_up_duration = 3
|
||||
|
||||
return (game, agent)
|
||||
|
||||
|
||||
def test_terminal_creation(terminal_on_computer):
|
||||
terminal, computer = terminal_on_computer
|
||||
terminal.describe_state()
|
||||
@@ -273,10 +284,10 @@ def test_terminal_receives_requests(game_and_agent_fixture: Tuple[PrimaiteGame,
|
||||
game, agent = game_and_agent_fixture
|
||||
|
||||
network: Network = game.simulation.network
|
||||
computer_a: Computer = network.get_node_by_hostname("node_a")
|
||||
computer_a: Computer = network.get_node_by_hostname("client_1")
|
||||
terminal_a: Terminal = computer_a.software_manager.software.get("Terminal")
|
||||
|
||||
computer_b: Computer = network.get_node_by_hostname("node_b")
|
||||
computer_b: Computer = network.get_node_by_hostname("client_2")
|
||||
|
||||
assert terminal_a.is_connected is False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user