From df50ec8abc65d08961cc49716925e6296f68b787 Mon Sep 17 00:00:00 2001 From: Czar Echavez Date: Thu, 25 Jul 2024 10:02:32 +0100 Subject: [PATCH] #2769: add change password action --- src/primaite/game/agent/actions.py | 8 ++++---- src/primaite/simulator/network/hardware/base.py | 5 ++++- .../test_user_account_change_password.py | 13 +++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 tests/integration_tests/game_layer/actions/user_account_actions/test_user_account_change_password.py diff --git a/src/primaite/game/agent/actions.py b/src/primaite/game/agent/actions.py index bf8e4323..266c667b 100644 --- a/src/primaite/game/agent/actions.py +++ b/src/primaite/game/agent/actions.py @@ -1077,16 +1077,16 @@ class NodeAccountsChangePasswordAction(AbstractAction): def __init__(self, manager: "ActionManager", **kwargs) -> None: super().__init__(manager=manager) - def form_request(self) -> RequestFormat: + def form_request(self, node_id: str) -> RequestFormat: """Return the action formatted as a request which can be ingested by the PrimAITE simulation.""" - pass + return ["network", "node", node_id, "change_password"] class NodeSessionsRemoteLoginAction(AbstractAction): """Action which performs a remote session login.""" def __init__(self, manager: "ActionManager", **kwargs) -> None: - pass + super().__init__(manager=manager) def form_request(self, node_id: str) -> RequestFormat: """Return the action formatted as a request which can be ingested by the PrimAITE simulation.""" @@ -1097,7 +1097,7 @@ class NodeSessionsRemoteLogoutAction(AbstractAction): """Action which performs a remote session logout.""" def __init__(self, manager: "ActionManager", **kwargs) -> None: - pass + super().__init__(manager=manager) def form_request(self, node_id: str) -> RequestFormat: """Return the action formatted as a request which can be ingested by the PrimAITE simulation.""" diff --git a/src/primaite/simulator/network/hardware/base.py b/src/primaite/simulator/network/hardware/base.py index 831a8539..3ef33ac3 100644 --- a/src/primaite/simulator/network/hardware/base.py +++ b/src/primaite/simulator/network/hardware/base.py @@ -1071,7 +1071,10 @@ class Node(SimComponent): rm.add_request( "logoff", RequestType(func=lambda request, context: RequestResponse.from_bool(False), validator=_node_is_on) ) # TODO implement logoff request - + rm.add_request( + "change_password", + RequestType(func=lambda request, context: RequestResponse.from_bool(False), validator=_node_is_on), + ) # TODO implement change_password request rm.add_request( "remote_logon", RequestType(func=lambda request, context: RequestResponse.from_bool(False), validator=_node_is_on), diff --git a/tests/integration_tests/game_layer/actions/user_account_actions/test_user_account_change_password.py b/tests/integration_tests/game_layer/actions/user_account_actions/test_user_account_change_password.py new file mode 100644 index 00000000..27328100 --- /dev/null +++ b/tests/integration_tests/game_layer/actions/user_account_actions/test_user_account_change_password.py @@ -0,0 +1,13 @@ +# © Crown-owned copyright 2024, Defence Science and Technology Laboratory UK +def test_remote_logon(game_and_agent): + """Test that the remote session login action works.""" + game, agent = game_and_agent + + action = ( + "NODE_ACCOUNTS_CHANGEPASSWORD", + {"node_id": 0}, + ) + agent.store_action(action) + game.step() + + # TODO Assert that the user account password is changed