forked from p15670423/monkey
Agent: Add get_agent_id()
This commit is contained in:
parent
78f792aee9
commit
160d2d11cf
|
@ -0,0 +1,17 @@
|
||||||
|
from uuid import UUID, uuid4
|
||||||
|
|
||||||
|
|
||||||
|
def get_agent_id() -> UUID:
|
||||||
|
"""
|
||||||
|
Get the agent ID for the current running agent
|
||||||
|
|
||||||
|
Each time an agent process starts, the return value of this function will be unique. Subsequent
|
||||||
|
calls to this function from within the same process will have the same return value.
|
||||||
|
"""
|
||||||
|
if get_agent_id._id is None:
|
||||||
|
get_agent_id._id = uuid4()
|
||||||
|
|
||||||
|
return get_agent_id._id
|
||||||
|
|
||||||
|
|
||||||
|
get_agent_id._id = None
|
|
@ -0,0 +1,10 @@
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
from infection_monkey.utils.agent_id import get_agent_id
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_agent_id():
|
||||||
|
agent_id = get_agent_id()
|
||||||
|
|
||||||
|
assert isinstance(agent_id, UUID)
|
||||||
|
assert agent_id == get_agent_id()
|
Loading…
Reference in New Issue