Add docs and tests
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""User account simulation."""
|
||||
from enum import Enum
|
||||
from typing import Any, Callable, Dict, List
|
||||
from typing import Dict
|
||||
|
||||
from primaite import getLogger
|
||||
from primaite.simulator.core import SimComponent
|
||||
@@ -49,6 +49,10 @@ class Account(SimComponent):
|
||||
"Account Type, currently this can be service account (used by apps) or user account."
|
||||
status: AccountStatus = AccountStatus.disabled
|
||||
|
||||
def describe_state(self) -> Dict:
|
||||
"""Describe state for agent observations."""
|
||||
return super().describe_state()
|
||||
|
||||
def enable(self):
|
||||
"""Set the status to enabled."""
|
||||
self.status = AccountStatus.enabled
|
||||
@@ -57,8 +61,10 @@ class Account(SimComponent):
|
||||
"""Set the status to disabled."""
|
||||
self.status = AccountStatus.disabled
|
||||
|
||||
def _possible_actions(self) -> Dict[str, Callable[[List[str]], None]]:
|
||||
return {
|
||||
"enable": self.enable,
|
||||
"disable": self.disable,
|
||||
}
|
||||
def log_on(self) -> None:
|
||||
"""TODO."""
|
||||
self.num_logons += 1
|
||||
|
||||
def log_off(self) -> None:
|
||||
"""TODO."""
|
||||
self.num_logoffs += 1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from enum import Enum
|
||||
from typing import Any, Dict, Final, List
|
||||
from typing import Dict, Final, List, Literal, Tuple
|
||||
|
||||
from primaite.simulator.core import ActionPermissionValidator, SimComponent
|
||||
from primaite.simulator.domain.account import Account, AccountType
|
||||
@@ -7,18 +7,26 @@ from primaite.simulator.domain.account import Account, AccountType
|
||||
|
||||
# placeholder while these objects don't yet exist
|
||||
class temp_node:
|
||||
"""Placeholder for node class for type hinting purposes."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class temp_application:
|
||||
"""Placeholder for application class for type hinting purposes."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class temp_folder:
|
||||
"""Placeholder for folder class for type hinting purposes."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class temp_file:
|
||||
"""Placeholder for file class for type hinting purposes."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@@ -59,9 +67,12 @@ class DomainController(SimComponent):
|
||||
accounts: List[Account] = []
|
||||
groups: Final[List[AccountGroup]] = list(AccountGroup)
|
||||
|
||||
group_membership: Dict[AccountGroup, List[Account]]
|
||||
domain_group_membership: Dict[Literal[AccountGroup.domain_admin, AccountGroup.domain_user], List[Account]] = {}
|
||||
local_group_membership: Dict[
|
||||
Tuple(temp_node, Literal[AccountGroup.local_admin, AccountGroup.local_user]), List[Account]
|
||||
] = {}
|
||||
|
||||
# references to non-owned objects
|
||||
# references to non-owned objects. Not sure if all are needed here.
|
||||
nodes: List[temp_node] = []
|
||||
applications: List[temp_application] = []
|
||||
folders: List[temp_folder] = []
|
||||
@@ -79,6 +90,10 @@ class DomainController(SimComponent):
|
||||
"""TODO."""
|
||||
...
|
||||
|
||||
def delete_account(self, account: Account) -> None:
|
||||
"""TODO."""
|
||||
...
|
||||
|
||||
def rotate_all_credentials(self) -> None:
|
||||
"""TODO."""
|
||||
...
|
||||
@@ -94,3 +109,15 @@ class DomainController(SimComponent):
|
||||
def remove_account_from_group(self, account: Account, group: AccountGroup) -> None:
|
||||
"""TODO."""
|
||||
...
|
||||
|
||||
def check_account_permissions(self, account: Account, node: temp_node) -> List[AccountGroup]:
|
||||
"""Return a list of permission groups that this account has on this node."""
|
||||
...
|
||||
|
||||
def register_node(self, node: temp_node) -> None:
|
||||
"""TODO."""
|
||||
...
|
||||
|
||||
def deregister_node(self, node: temp_node) -> None:
|
||||
"""TODO."""
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user