agent: Resolve empty space in build_monkey_commandline

This commit is contained in:
Ilija Lazoroski 2021-06-21 21:00:04 +02:00 committed by Ilija Lazoroski
parent 5a871da26a
commit feaa7ee867
2 changed files with 16 additions and 1 deletions

View File

@ -7,7 +7,7 @@ def build_monkey_commandline(
target_host: VictimHost, depth: int, vulnerable_port: str, location: str = None target_host: VictimHost, depth: int, vulnerable_port: str, location: str = None
) -> str: ) -> str:
return "".join( return " ".join(
build_monkey_commandline_explicitly( build_monkey_commandline_explicitly(
GUID, GUID,
target_host.default_tunnel, target_host.default_tunnel,

View File

@ -1,4 +1,7 @@
from infection_monkey.config import GUID
from infection_monkey.model.host import VictimHost
from infection_monkey.utils.commands import ( from infection_monkey.utils.commands import (
build_monkey_commandline,
build_monkey_commandline_explicitly, build_monkey_commandline_explicitly,
get_monkey_commandline_linux, get_monkey_commandline_linux,
get_monkey_commandline_windows, get_monkey_commandline_windows,
@ -91,3 +94,15 @@ def test_get_monkey_commandline_linux():
) )
assert expected == actual assert expected == actual
def test_build_monkey_commandline():
example_host = VictimHost(ip_addr="bla")
example_host.set_default_server("101010")
expected = "-p " + GUID + " -s 101010 -d 0 -l /home/bla -vp 80"
actual = build_monkey_commandline(
target_host=example_host, depth=0, vulnerable_port="80", location="/home/bla"
)
assert expected == actual