mirror of
https://github.com/Av0idD4rk/firegex.git
synced 2026-10-23 15:30:59 +00:00
fix(nfproxy): export HttpHistory in nfproxy and ensure list immutability in getters
This commit is contained in:
parent
dbc8b176b1
commit
c71ad7c199
@ -1,5 +1,13 @@
|
||||
import functools
|
||||
from firegex.nfproxy.models import RawPacket, TCPInputStream, TCPOutputStream, TCPClientStream, TCPServerStream
|
||||
from firegex.nfproxy.models import (
|
||||
RawPacket,
|
||||
TCPInputStream,
|
||||
TCPOutputStream,
|
||||
TCPClientStream,
|
||||
TCPServerStream,
|
||||
HttpHistory,
|
||||
HttpStreamHistory,
|
||||
)
|
||||
from firegex.nfproxy.internals.models import Action, FullStreamAction
|
||||
|
||||
ACCEPT = Action.ACCEPT
|
||||
|
||||
@ -411,12 +411,12 @@ class HttpHistory:
|
||||
@property
|
||||
def requests(self) -> list["HttpFullRequest"]:
|
||||
"""List of previous completed HTTP requests"""
|
||||
return self._requests
|
||||
return self._requests.copy()
|
||||
|
||||
@property
|
||||
def responses(self) -> list["HttpFullResponse"]:
|
||||
"""List of previous completed HTTP responses"""
|
||||
return self._responses
|
||||
return self._responses.copy()
|
||||
|
||||
@classmethod
|
||||
def _fetch_packet(cls, internal_data: DataStreamCtx):
|
||||
|
||||
@ -264,6 +264,25 @@ def filter_req(req: HttpFullRequest):
|
||||
handle_packet(glob)
|
||||
|
||||
|
||||
def test_http_history_nfproxy_import():
|
||||
from firegex.nfproxy import HttpHistory as HH1, HttpStreamHistory as HH2
|
||||
assert HH1 is HttpHistory
|
||||
assert HH2 is HttpStreamHistory
|
||||
|
||||
|
||||
def test_http_history_list_mutation():
|
||||
history_obj = HttpHistory(requests=["dummy_req"], responses=["dummy_resp"])
|
||||
reqs = history_obj.requests
|
||||
reqs.clear()
|
||||
assert len(history_obj.requests) == 1
|
||||
assert history_obj.requests == ["dummy_req"]
|
||||
|
||||
resps = history_obj.responses
|
||||
resps.append("extra_resp")
|
||||
assert len(history_obj.responses) == 1
|
||||
assert history_obj.responses == ["dummy_resp"]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_http_history_model()
|
||||
test_http_history_stream_execution()
|
||||
@ -272,6 +291,9 @@ if __name__ == "__main__":
|
||||
test_http_history_parameter_order()
|
||||
test_http_history_property_immutability()
|
||||
test_http_history_negative_max_size()
|
||||
test_http_history_nfproxy_import()
|
||||
test_http_history_list_mutation()
|
||||
print("All HTTP history unit tests passed successfully!")
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user