agent: Modify unit test for commands

This commit is contained in:
Ilija Lazoroski 2021-06-18 12:29:36 +02:00 committed by Ilija Lazoroski
parent 36a9e02181
commit af974fae70
1 changed files with 23 additions and 41 deletions

View File

@ -5,8 +5,8 @@ from infection_monkey.utils.commands import (
) )
def test_build_monkey_commandline_explicitly(): def test_build_monkey_commandline_explicitly_arguments():
test1 = [ expected = [
"-p", "-p",
"101010", "101010",
"-t", "-t",
@ -20,53 +20,35 @@ def test_build_monkey_commandline_explicitly():
"-vp", "-vp",
"80", "80",
] ]
result1 = build_monkey_commandline_explicitly( actual = build_monkey_commandline_explicitly(
101010, "10.10.101.10", "127.127.127.127:5000", 0, "C:\\windows\\abc", 80 101010, "10.10.101.10", "127.127.127.127:5000", 0, "C:\\windows\\abc", 80
) )
test2 = [ assert expected == actual
"-p",
"101010",
"-t", def test_build_monkey_commandline_explicitly_depth_condition_less():
"10.10.101.10", expected = [
"-s",
"200.150.100.50:5000",
"-d", "-d",
"0", "0",
"-l",
"C:\\windows\\abc",
"-vp",
"443",
] ]
result2 = build_monkey_commandline_explicitly( actual = build_monkey_commandline_explicitly(depth=-50)
101010, "10.10.101.10", "200.150.100.50:5000", -50, "C:\\windows\\abc", 443
)
test3 = [ assert expected == actual
"-p",
"101010",
"-t", def test_build_monkey_commandline_explicitly_depth_condition_greater():
"10.10.101.10", expected = [
"-s",
"200.150.100.50:5000",
"-d", "-d",
"100", "50",
"-l",
"C:\\windows\\ghi",
"-vp",
"443",
] ]
result3 = build_monkey_commandline_explicitly( actual = build_monkey_commandline_explicitly(depth=50)
101010, "10.10.101.10", "200.150.100.50:5000", 100, "C:\\windows\\ghi", 443
)
assert test1 == result1 assert expected == actual
assert test2 == result2
assert test3 == result3
def test_get_monkey_commandline_windows(): def test_get_monkey_commandline_windows():
test1 = [ expected = [
"cmd.exe", "cmd.exe",
"/c", "/c",
"C:\\windows\\abc", "C:\\windows\\abc",
@ -76,7 +58,7 @@ def test_get_monkey_commandline_windows():
"-t", "-t",
"10.10.101.10", "10.10.101.10",
] ]
result1 = get_monkey_commandline_windows( actual = get_monkey_commandline_windows(
"C:\\windows\\abc", "C:\\windows\\abc",
[ [
"-p", "-p",
@ -86,11 +68,11 @@ def test_get_monkey_commandline_windows():
], ],
) )
assert test1 == result1 assert expected == actual
def test_get_monkey_commandline_linux(): def test_get_monkey_commandline_linux():
test1 = [ expected = [
"monkey-linux-64", "monkey-linux-64",
"m0nk3y", "m0nk3y",
"-p", "-p",
@ -98,7 +80,7 @@ def test_get_monkey_commandline_linux():
"-t", "-t",
"10.10.101.10", "10.10.101.10",
] ]
result1 = get_monkey_commandline_linux( actual = get_monkey_commandline_linux(
"/home/user/monkey-linux-64", "/home/user/monkey-linux-64",
[ [
"-p", "-p",
@ -108,4 +90,4 @@ def test_get_monkey_commandline_linux():
], ],
) )
assert test1 == result1 assert expected == actual