#!/usr/bin/env python3 import pdb import queue import pytest from networkthread import bPacket, bRequest, bResponse, bHeader, NetworkThread, FlowItem, bFlowState import os import tempfile from queue import Queue import zmq from deepdiff import DeepDiff # usual flow state of the request with some big parts removed @pytest.fixture def flowstate_request(): return {'client_conn': {'address': ('::ffff:127.0.0.1', 60630, 0, 0), 'alpn_proto_negotiated': b'http/1.1', 'cipher_name': 'TLS_AES_256_GCM_SHA384', 'clientcert': None, 'id': '5dde7ef8-9b1a-4b60-9d15-d308442a27ea', 'mitmcert': '', 'sni': 'yolo.jetzt', 'timestamp_end': None, 'timestamp_start': 1619390481.8003347, 'timestamp_tls_setup': 1619390482.6879823, 'tls_established': True, 'tls_extensions': [], 'tls_version': 'TLSv1.3'}, 'error': None, 'id': '51215b69-c76f-4ac2-afcb-da3b823d9f88', 'intercepted': False, 'is_replay': None, 'marked': False, 'metadata': {}, 'mode': 'transparent', 'request': {'authority': b'', 'content': b'', 'headers': ((b'Host', b'yolo.jetzt'), (b'User-Agent', b'curl/7.75.0'), (b'Accept', b'*/*')), 'host': 'yolo.jetzt', 'http_version': b'HTTP/1.1', 'method': b'GET', 'path': b'/', 'port': 443, 'scheme': b'https', 'timestamp_end': 1619390482.69, 'timestamp_start': 1619390482.6886377, 'trailers': None}, 'response': None, 'server_conn': {'address': ('yolo.jetzt', 443), 'alpn_proto_negotiated': b'http/1.1', 'cert': '', 'id': 'ecc4cd3b-7e35-4815-b618-5931fe64729b', 'ip_address': ('95.156.226.69', 443), 'sni': 'yolo.jetzt', 'source_address': ('192.168.42.182', 51514), 'timestamp_end': None, 'timestamp_start': 1619390481.8154442, 'timestamp_tcp_setup': 1619390481.994565, 'timestamp_tls_setup': 1619390482.6819758, 'tls_established': True, 'tls_version': 'TLSv1.2', 'via': None}, 'type': 'http', 'version': 9} @pytest.fixture() def flowstate_response(): return {'client_conn': {'address': ('::ffff:127.0.0.1', 30190, 0, 0), 'alpn_proto_negotiated': b'http/1.1', 'cipher_name': 'TLS_AES_256_GCM_SHA384', 'clientcert': None, 'id': '2507e6ce-3132-4394-9432-f55fb5f55b05', 'mitmcert': '', 'sni': 'yolo.jetzt', 'timestamp_end': None, 'timestamp_start': 1619461916.6160116, 'timestamp_tls_setup': 1619461916.7581937, 'tls_established': True, 'tls_extensions': [], 'tls_version': 'TLSv1.3'}, 'error': None, 'id': '449d1a87-744f-4a18-9a5d-f085f99a5c62', 'intercepted': True, 'is_replay': None, 'marked': False, 'metadata': {}, 'mode': 'transparent', 'request': {'authority': b'', 'content': b'', 'headers': ((b'Host', b'yolo.jetzt'), (b'User-Agent', b'curl/7.75.0'), (b'Accept', b'*/*')), 'host': 'yolo.jetzt', 'http_version': b'HTTP/1.1', 'method': b'GET', 'path': b'/', 'port': 443, 'scheme': b'https', 'timestamp_end': 1619461916.7603076, 'timestamp_start': 1619461916.7588415, 'trailers': None}, 'response': {'content': b'\n\n
\n\n