forked from p15670423/monkey
Agent: Add get_machine_id()
This commit is contained in:
parent
160d2d11cf
commit
09739268fa
|
@ -1,4 +1,4 @@
|
||||||
from uuid import UUID, uuid4
|
from uuid import UUID, getnode, uuid4
|
||||||
|
|
||||||
|
|
||||||
def get_agent_id() -> UUID:
|
def get_agent_id() -> UUID:
|
||||||
|
@ -15,3 +15,8 @@ def get_agent_id() -> UUID:
|
||||||
|
|
||||||
|
|
||||||
get_agent_id._id = None
|
get_agent_id._id = None
|
||||||
|
|
||||||
|
|
||||||
|
def get_machine_id() -> int:
|
||||||
|
"""Get an integer that uniquely defines the machine the agent is running on"""
|
||||||
|
return getnode()
|
|
@ -1,10 +0,0 @@
|
||||||
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()
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
from infection_monkey.utils.ids import get_agent_id, get_machine_id
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_agent_id():
|
||||||
|
agent_id = get_agent_id()
|
||||||
|
|
||||||
|
assert isinstance(agent_id, UUID)
|
||||||
|
assert agent_id == get_agent_id()
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_machine_id():
|
||||||
|
machine_id = get_machine_id()
|
||||||
|
|
||||||
|
assert isinstance(machine_id, int)
|
||||||
|
assert machine_id == get_machine_id()
|
Loading…
Reference in New Issue