2
2
from http import HTTPStatus
3
3
from http .server import HTTPServer
4
4
from io import BytesIO
5
- from typing import Type
5
+ from typing import Final , Type
6
6
from unittest .mock import MagicMock
7
7
8
8
import pytest
20
20
get_http_handler ,
21
21
)
22
22
23
- AGENT_BINARY = b"agent_binary"
24
- DROPPER_BINARY = b"dropper_agent_binary"
25
- IP = "127.0.0.1"
26
- UUID_1 = ReservationID ("00000000-0000-0000-0000-000000000001 " )
27
- UUID_2 = ReservationID ("00000000-0000-0000-0000-000000000002 " )
28
- UUID_3 = ReservationID ("00000000-0000-0000-0000-000000000003 " )
23
+ AGENT_BINARY : Final = b"agent_binary"
24
+ DROPPER_BINARY : Final = b"dropper_agent_binary"
25
+ IP : Final = "127.0.0.1"
26
+ RESERVATION_ID_1 : Final = ReservationID ("abcABC1 " )
27
+ RESERVATION_ID_2 : Final = ReservationID ("abcABC2 " )
28
+ RESERVATION_ID_3 : Final = ReservationID ("abcABC2 " )
29
29
30
-
31
- DEFAULT_AGENT_TEMPLATE = b"%(agent_binary)s"
32
- DROPPER_AGENT_TEMPLATE = b"dropper_%(agent_binary)s"
30
+ DEFAULT_AGENT_TEMPLATE : Final = b"%(agent_binary)s"
31
+ DROPPER_AGENT_TEMPLATE : Final = b"dropper_%(agent_binary)s"
33
32
34
33
35
34
@pytest .fixture
@@ -40,54 +39,54 @@ def port(tcp_port_selector) -> int:
40
39
@pytest .fixture
41
40
def binary_request_1 (port ) -> AgentBinaryDownloadReservation :
42
41
return AgentBinaryDownloadReservation (
43
- UUID_1 ,
42
+ RESERVATION_ID_1 ,
44
43
OperatingSystem .LINUX ,
45
44
DEFAULT_AGENT_TEMPLATE ,
46
- f"http://{ IP } :{ port } /{ UUID_1 } " ,
45
+ f"http://{ IP } :{ port } /{ RESERVATION_ID_1 } " ,
47
46
threading .Event (),
48
47
)
49
48
50
49
51
50
@pytest .fixture
52
51
def binary_request_2 (port ) -> AgentBinaryDownloadReservation :
53
52
return AgentBinaryDownloadReservation (
54
- UUID_2 ,
53
+ RESERVATION_ID_2 ,
55
54
OperatingSystem .WINDOWS ,
56
55
DEFAULT_AGENT_TEMPLATE ,
57
- f"http://{ IP } :{ port } /{ UUID_2 } " ,
56
+ f"http://{ IP } :{ port } /{ RESERVATION_ID_2 } " ,
58
57
threading .Event (),
59
58
)
60
59
61
60
62
61
@pytest .fixture
63
62
def binary_request_3 (port ) -> AgentBinaryDownloadReservation :
64
63
return AgentBinaryDownloadReservation (
65
- UUID_2 ,
64
+ RESERVATION_ID_2 ,
66
65
OperatingSystem .WINDOWS ,
67
66
None ,
68
- f"http://{ IP } :{ port } /{ UUID_2 } " ,
67
+ f"http://{ IP } :{ port } /{ RESERVATION_ID_2 } " ,
69
68
threading .Event (),
70
69
)
71
70
72
71
73
72
@pytest .fixture
74
73
def dropper_request_1 (port ) -> AgentBinaryDownloadReservation :
75
74
return AgentBinaryDownloadReservation (
76
- UUID_1 ,
75
+ RESERVATION_ID_1 ,
77
76
OperatingSystem .LINUX ,
78
77
DROPPER_AGENT_TEMPLATE ,
79
- f"http://{ IP } :{ port } /{ UUID_1 } " ,
78
+ f"http://{ IP } :{ port } /{ RESERVATION_ID_1 } " ,
80
79
threading .Event (),
81
80
)
82
81
83
82
84
83
@pytest .fixture
85
84
def dropper_request_2 (port ) -> AgentBinaryDownloadReservation :
86
85
return AgentBinaryDownloadReservation (
87
- UUID_2 ,
86
+ RESERVATION_ID_2 ,
88
87
OperatingSystem .WINDOWS ,
89
88
DROPPER_AGENT_TEMPLATE ,
90
- f"http://{ IP } :{ port } /{ UUID_2 } " ,
89
+ f"http://{ IP } :{ port } /{ RESERVATION_ID_2 } " ,
91
90
threading .Event (),
92
91
)
93
92
@@ -302,3 +301,4 @@ def test_agent_binary_request__is_transformed(
302
301
303
302
assert response .status_code == HTTPStatus .OK
304
303
assert response .content == DROPPER_BINARY
304
+ assert response .content == DROPPER_BINARY
0 commit comments