#2735 - added documentation for users, usermanager and usersessionmanager. Added the ability to add additional users from config and documented this. also tested additional users from config.
This commit is contained in:
34
tests/assets/configs/basic_node_with_users.yaml
Normal file
34
tests/assets/configs/basic_node_with_users.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
io_settings:
|
||||
save_step_metadata: false
|
||||
save_pcap_logs: true
|
||||
save_sys_logs: true
|
||||
sys_log_level: WARNING
|
||||
agent_log_level: INFO
|
||||
save_agent_logs: true
|
||||
write_agent_log_to_terminal: True
|
||||
|
||||
|
||||
game:
|
||||
max_episode_length: 256
|
||||
ports:
|
||||
- ARP
|
||||
protocols:
|
||||
- ICMP
|
||||
- UDP
|
||||
|
||||
|
||||
simulation:
|
||||
network:
|
||||
nodes:
|
||||
- hostname: client_1
|
||||
type: computer
|
||||
ip_address: 192.168.10.11
|
||||
subnet_mask: 255.255.255.0
|
||||
default_gateway: 192.168.10.1
|
||||
users:
|
||||
- username: jane.doe
|
||||
password: '1234'
|
||||
is_admin: true
|
||||
- username: john.doe
|
||||
password: password_1
|
||||
is_admin: false
|
||||
@@ -0,0 +1,26 @@
|
||||
# © Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
|
||||
import yaml
|
||||
|
||||
from primaite.game.game import PrimaiteGame
|
||||
from primaite.simulator.network.hardware.base import UserManager
|
||||
from tests import TEST_ASSETS_ROOT
|
||||
|
||||
|
||||
def test_users_from_config():
|
||||
config_path = TEST_ASSETS_ROOT / "configs" / "basic_node_with_users.yaml"
|
||||
|
||||
with open(config_path, "r") as f:
|
||||
config_dict = yaml.safe_load(f)
|
||||
network = PrimaiteGame.from_config(cfg=config_dict).simulation.network
|
||||
|
||||
client_1 = network.get_node_by_hostname("client_1")
|
||||
|
||||
user_manager: UserManager = client_1.software_manager.software["UserManager"]
|
||||
|
||||
assert len(user_manager.users) == 3
|
||||
|
||||
assert user_manager.users["jane.doe"].password == "1234"
|
||||
assert user_manager.users["jane.doe"].is_admin
|
||||
|
||||
assert user_manager.users["john.doe"].password == "password_1"
|
||||
assert not user_manager.users["john.doe"].is_admin
|
||||
Reference in New Issue
Block a user