forked from p15670423/monkey
UT: Add test for thread-safety of ExploitClassHTTPServer
This commit is contained in:
parent
7739094cfd
commit
1ca9a21d43
|
@ -30,6 +30,16 @@ def server(ip, port, java_class):
|
||||||
server.stop()
|
server.stop()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def second_server(ip, java_class):
|
||||||
|
server = ExploitClassHTTPServer(ip, get_free_tcp_port(), java_class, 0.01)
|
||||||
|
server.run()
|
||||||
|
|
||||||
|
yield server
|
||||||
|
|
||||||
|
server.stop()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def exploit_url(ip, port):
|
def exploit_url(ip, port):
|
||||||
return f"http://{ip}:{port}/Exploit"
|
return f"http://{ip}:{port}/Exploit"
|
||||||
|
@ -52,3 +62,13 @@ def test_exploit_class_downloaded(server, exploit_url):
|
||||||
requests.get(exploit_url)
|
requests.get(exploit_url)
|
||||||
|
|
||||||
assert server.exploit_class_downloaded()
|
assert server.exploit_class_downloaded()
|
||||||
|
|
||||||
|
|
||||||
|
def test_thread_safety(server, second_server, exploit_url):
|
||||||
|
assert not server.exploit_class_downloaded()
|
||||||
|
assert not second_server.exploit_class_downloaded()
|
||||||
|
|
||||||
|
requests.get(exploit_url)
|
||||||
|
|
||||||
|
assert server.exploit_class_downloaded()
|
||||||
|
assert not second_server.exploit_class_downloaded()
|
||||||
|
|
Loading…
Reference in New Issue