diff --git a/src/primaite/game/agent/actions.py b/src/primaite/game/agent/actions.py index 7c908f42..2ddeff3d 100644 --- a/src/primaite/game/agent/actions.py +++ b/src/primaite/game/agent/actions.py @@ -1079,7 +1079,18 @@ class NodeAccountsChangePasswordAction(AbstractAction): def form_request(self, node_id: str, username: str, current_password: str, new_password: str) -> RequestFormat: """Return the action formatted as a request which can be ingested by the PrimAITE simulation.""" - return ["network", "node", node_id, "accounts", "change_password", username, current_password, new_password] + node_name = self.manager.get_node_name_by_idx(node_id) + return [ + "network", + "node", + node_name, + "service", + "UserManager", + "change_password", + username, + current_password, + new_password, + ] class NodeSessionsRemoteLoginAction(AbstractAction): @@ -1088,9 +1099,21 @@ class NodeSessionsRemoteLoginAction(AbstractAction): def __init__(self, manager: "ActionManager", **kwargs) -> None: super().__init__(manager=manager) - def form_request(self, node_id: str, username: str, password: str) -> RequestFormat: + def form_request(self, node_id: str, username: str, password: str, remote_ip: str) -> RequestFormat: """Return the action formatted as a request which can be ingested by the PrimAITE simulation.""" - return ["network", "node", node_id, "sessions", "remote_login", username, password] + # TODO: change this so it creates a remote connection using terminal rather than a local remote login + node_name = self.manager.get_node_name_by_idx(node_id) + return [ + "network", + "node", + node_name, + "service", + "UserSessionManager", + "remote_login", + username, + password, + remote_ip, + ] class NodeSessionsRemoteLogoutAction(AbstractAction): @@ -1101,7 +1124,9 @@ class NodeSessionsRemoteLogoutAction(AbstractAction): def form_request(self, node_id: str, remote_session_id: str) -> RequestFormat: """Return the action formatted as a request which can be ingested by the PrimAITE simulation.""" - return ["network", "node", node_id, "sessions", "remote_logout", remote_session_id] + # TODO: change this so it destroys a remote connection using terminal rather than a local remote login + node_name = self.manager.get_node_name_by_idx(node_id) + return ["network", "node", node_name, "service", "UserSessionManager", "remote_logout", remote_session_id] class ActionManager: diff --git a/tests/integration_tests/game_layer/actions/user_account_actions/test_remote_user_account_actions.py b/tests/integration_tests/game_layer/actions/user_account_actions/test_remote_user_account_actions.py index 2e282d77..25079226 100644 --- a/tests/integration_tests/game_layer/actions/user_account_actions/test_remote_user_account_actions.py +++ b/tests/integration_tests/game_layer/actions/user_account_actions/test_remote_user_account_actions.py @@ -12,7 +12,7 @@ def test_remote_logon(game_and_agent): action = ( "NODE_SESSIONS_REMOTE_LOGIN", - {"node_id": 0, "username": "test_user", "password": "password"}, + {"node_id": 0, "username": "test_user", "password": "password", "remote_ip": "10.0.2.2"}, ) agent.store_action(action) game.step()