repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/test_commands.py
test/mitmproxy/proxy/test_commands.py
from dataclasses import dataclass import pytest from mitmproxy import connection from mitmproxy.hooks import all_hooks from mitmproxy.proxy import commands @pytest.fixture def tconn() -> connection.Server: return connection.Server(address=None) def test_dataclasses(tconn): assert repr(commands.RequestWake...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/test_events.py
test/mitmproxy/proxy/test_events.py
from unittest.mock import Mock import pytest from mitmproxy import connection from mitmproxy.proxy import commands from mitmproxy.proxy import events @pytest.fixture def tconn() -> connection.Server: return connection.Server(address=None) def test_dataclasses(tconn): assert repr(events.Start()) assert...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/test_dns.py
test/mitmproxy/proxy/layers/test_dns.py
import struct import time import pytest from hypothesis import given from hypothesis import HealthCheck from hypothesis import settings from hypothesis import strategies as st from ..tutils import Placeholder from ..tutils import Playbook from ..tutils import reply from mitmproxy.dns import DNSFlow from mitmproxy.net...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/test_udp.py
test/mitmproxy/proxy/layers/test_udp.py
import pytest from ..tutils import Placeholder from ..tutils import Playbook from ..tutils import reply from mitmproxy.proxy.commands import CloseConnection from mitmproxy.proxy.commands import OpenConnection from mitmproxy.proxy.commands import SendData from mitmproxy.proxy.events import ConnectionClosed from mitmpro...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/test_tls_fuzz.py
test/mitmproxy/proxy/layers/test_tls_fuzz.py
from hypothesis import example from hypothesis import given from hypothesis.strategies import binary from hypothesis.strategies import integers from mitmproxy.proxy.layers.tls import parse_client_hello from mitmproxy.tls import ClientHello client_hello_with_extensions = bytes.fromhex( "16030300bb" # record layer...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/test_tcp.py
test/mitmproxy/proxy/layers/test_tcp.py
import pytest from ..tutils import Placeholder from ..tutils import Playbook from ..tutils import reply from mitmproxy.proxy.commands import CloseConnection from mitmproxy.proxy.commands import CloseTcpConnection from mitmproxy.proxy.commands import OpenConnection from mitmproxy.proxy.commands import SendData from mit...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/__init__.py
test/mitmproxy/proxy/layers/__init__.py
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/test_websocket.py
test/mitmproxy/proxy/layers/test_websocket.py
import secrets from dataclasses import dataclass import pytest import wsproto.events from wsproto.frame_protocol import Opcode from mitmproxy.connection import ConnectionState from mitmproxy.http import HTTPFlow from mitmproxy.http import Request from mitmproxy.http import Response from mitmproxy.proxy.commands impor...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/test_tls.py
test/mitmproxy/proxy/layers/test_tls.py
import ssl import sys import time from logging import DEBUG from logging import WARNING import pytest from OpenSSL import SSL from mitmproxy import connection from mitmproxy.connection import ConnectionState from mitmproxy.connection import Server from mitmproxy.proxy import commands from mitmproxy.proxy import conte...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
true
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/test_modes.py
test/mitmproxy/proxy/layers/test_modes.py
import copy import pytest from mitmproxy import dns from mitmproxy.addons.proxyauth import ProxyAuth from mitmproxy.connection import Client from mitmproxy.connection import ConnectionState from mitmproxy.connection import Server from mitmproxy.proxy import layers from mitmproxy.proxy.commands import CloseConnection ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/test_socks5_fuzz.py
test/mitmproxy/proxy/layers/test_socks5_fuzz.py
from hypothesis import given from hypothesis.strategies import binary from mitmproxy import options from mitmproxy.connection import Client from mitmproxy.proxy.context import Context from mitmproxy.proxy.events import DataReceived from mitmproxy.proxy.layers.modes import Socks5Proxy opts = options.Options() tctx = C...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/quic/test__client_hello_parser.py
test/mitmproxy/proxy/layers/quic/test__client_hello_parser.py
import pytest from aioquic.quic.connection import QuicConnection from aioquic.quic.connection import QuicConnectionError from mitmproxy.proxy.layers.quic import _client_hello_parser from mitmproxy.proxy.layers.quic._client_hello_parser import ( quic_parse_client_hello_from_datagrams, ) from test.mitmproxy.proxy.la...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/quic/test__hooks.py
test/mitmproxy/proxy/layers/quic/test__hooks.py
from mitmproxy.options import Options from mitmproxy.proxy.context import Context from mitmproxy.proxy.layers.quic._hooks import QuicStartServerHook from mitmproxy.proxy.layers.quic._hooks import QuicTlsData from mitmproxy.proxy.layers.quic._hooks import QuicTlsSettings from mitmproxy.test.tflow import tclient_conn d...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/quic/test__stream_layers.py
test/mitmproxy/proxy/layers/quic/test__stream_layers.py
import ssl import time from logging import DEBUG from logging import ERROR from logging import WARNING from typing import Literal from typing import TypeVar from unittest.mock import MagicMock import pytest from aioquic.buffer import Buffer as QuicBuffer from aioquic.quic import events as quic_events from aioquic.quic...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
true
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/quic/__init__.py
test/mitmproxy/proxy/layers/quic/__init__.py
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/quic/test__events.py
test/mitmproxy/proxy/layers/quic/test__events.py
from mitmproxy.proxy.layers.quic._events import QuicConnectionClosed from mitmproxy.proxy.layers.quic._events import QuicStreamDataReceived from mitmproxy.test.tflow import tclient_conn def test_reprs(): client = tclient_conn() assert repr(QuicStreamDataReceived(client, 42, b"data", end_stream=False)) ass...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/quic/test__commands.py
test/mitmproxy/proxy/layers/quic/test__commands.py
from mitmproxy.proxy.layers.quic._commands import CloseQuicConnection from mitmproxy.proxy.layers.quic._commands import QuicStreamCommand from mitmproxy.proxy.layers.quic._commands import ResetQuicStream from mitmproxy.proxy.layers.quic._commands import SendQuicStreamData from mitmproxy.proxy.layers.quic._commands impo...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/quic/test__raw_layers.py
test/mitmproxy/proxy/layers/quic/test__raw_layers.py
import pytest from mitmproxy import connection from mitmproxy.proxy import commands from mitmproxy.proxy import context from mitmproxy.proxy import events from mitmproxy.proxy import layer from mitmproxy.proxy import layers from mitmproxy.proxy import tunnel from mitmproxy.proxy.layers import tcp from mitmproxy.proxy....
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/http/test_http3.py
test/mitmproxy/proxy/layers/http/test_http3.py
from collections.abc import Callable from collections.abc import Iterable import pylsqpack import pytest from aioquic._buffer import Buffer from aioquic.h3.connection import encode_frame from aioquic.h3.connection import encode_settings from aioquic.h3.connection import encode_uint_var from aioquic.h3.connection impor...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
true
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/http/test_http.py
test/mitmproxy/proxy/layers/http/test_http.py
import gc from logging import WARNING import pytest from mitmproxy.connection import ConnectionState from mitmproxy.connection import Server from mitmproxy.http import HTTPFlow from mitmproxy.http import Response from mitmproxy.proxy import layer from mitmproxy.proxy.commands import CloseConnection from mitmproxy.pro...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
true
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/http/test_http_version_interop.py
test/mitmproxy/proxy/layers/http/test_http_version_interop.py
import h2.config import h2.connection import h2.events from mitmproxy.connection import Server from mitmproxy.http import HTTPFlow from mitmproxy.proxy.commands import CloseConnection from mitmproxy.proxy.commands import OpenConnection from mitmproxy.proxy.commands import SendData from mitmproxy.proxy.context import C...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/http/test_http2.py
test/mitmproxy/proxy/layers/http/test_http2.py
import time from logging import DEBUG import h2.settings import hpack import hyperframe.frame import pytest from h2.errors import ErrorCodes from mitmproxy.connection import ConnectionState from mitmproxy.connection import Server from mitmproxy.flow import Error from mitmproxy.http import Headers from mitmproxy.http ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
true
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/http/hyper_h2_test_helpers.py
test/mitmproxy/proxy/layers/http/hyper_h2_test_helpers.py
# This file has been copied from https://github.com/python-hyper/hyper-h2/blob/master/test/helpers.py, # MIT License # -*- coding: utf-8 -*- """ helpers ~~~~~~~ This module contains helpers for the h2 tests. """ from hpack.hpack import Encoder from hyperframe.frame import AltSvcFrame from hyperframe.frame import Cont...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/http/test_http1.py
test/mitmproxy/proxy/layers/http/test_http1.py
import pytest from mitmproxy import http from mitmproxy.proxy.commands import SendData from mitmproxy.proxy.events import DataReceived from mitmproxy.proxy.layers.http import Http1Client from mitmproxy.proxy.layers.http import Http1Server from mitmproxy.proxy.layers.http import ReceiveHttp from mitmproxy.proxy.layers....
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/proxy/layers/http/test_http_fuzz.py
test/mitmproxy/proxy/layers/http/test_http_fuzz.py
from typing import Any import pytest from h2.settings import SettingCodes from hypothesis import example from hypothesis import given from hypothesis.strategies import binary from hypothesis.strategies import booleans from hypothesis.strategies import composite from hypothesis.strategies import data from hypothesis.st...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_onboarding.py
test/mitmproxy/addons/test_onboarding.py
import pytest from mitmproxy.addons import onboarding from mitmproxy.test import taddons @pytest.fixture def client(): with onboarding.app.test_client() as client: yield client class TestApp: def addons(self): return [onboarding.Onboarding()] def test_basic(self, client): ob = ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_strip_dns_https_records.py
test/mitmproxy/addons/test_strip_dns_https_records.py
from mitmproxy import dns from mitmproxy.addons import strip_dns_https_records from mitmproxy.net.dns import https_records from mitmproxy.net.dns import types from mitmproxy.net.dns.https_records import SVCParamKeys from mitmproxy.test import taddons from mitmproxy.test import tflow from mitmproxy.test import tutils ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_modifybody.py
test/mitmproxy/addons/test_modifybody.py
import pytest from mitmproxy.addons import modifybody from mitmproxy.addons import proxyserver from mitmproxy.test import taddons from mitmproxy.test import tflow from mitmproxy.test.tutils import tresp class TestModifyBody: def test_configure(self): mb = modifybody.ModifyBody() with taddons.cont...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_tlsconfig.py
test/mitmproxy/addons/test_tlsconfig.py
import ipaddress import logging import ssl import time from pathlib import Path import pytest from cryptography import x509 from OpenSSL import SSL from mitmproxy import certs from mitmproxy import connection from mitmproxy import options from mitmproxy import tls from mitmproxy.addons import tlsconfig from mitmproxy...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_mapremote.py
test/mitmproxy/addons/test_mapremote.py
import pytest from mitmproxy.addons import mapremote from mitmproxy.test import taddons from mitmproxy.test import tflow class TestMapRemote: def test_configure(self): mr = mapremote.MapRemote() with taddons.context(mr) as tctx: tctx.configure(mr, map_remote=["one/two/three"]) ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_errorcheck.py
test/mitmproxy/addons/test_errorcheck.py
import logging import pytest from mitmproxy.addons.errorcheck import ErrorCheck from mitmproxy.tools import main @pytest.mark.parametrize("run_main", [main.mitmdump, main.mitmproxy]) def test_errorcheck(tdata, capsys, run_main): """Integration test: Make sure that we catch errors on startup an exit.""" with...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_anticomp.py
test/mitmproxy/addons/test_anticomp.py
from mitmproxy.addons import anticomp from mitmproxy.test import taddons from mitmproxy.test import tflow class TestAntiComp: def test_simple(self): sa = anticomp.AntiComp() with taddons.context(sa) as tctx: f = tflow.tflow(resp=True) sa.request(f) tctx.configu...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_core.py
test/mitmproxy/addons/test_core.py
import pytest from mitmproxy import exceptions from mitmproxy.addons import core from mitmproxy.test import taddons from mitmproxy.test import tflow def test_set(): sa = core.Core() with taddons.context(loadcore=False) as tctx: assert tctx.master.options.upstream_cert tctx.command(sa.set, "up...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_termlog.py
test/mitmproxy/addons/test_termlog.py
import builtins import io import logging import pytest from mitmproxy.addons import termlog from mitmproxy.test import taddons from mitmproxy.utils import vt_codes @pytest.fixture(autouse=True) def ensure_cleanup(): yield assert not any(isinstance(x, termlog.TermLogHandler) for x in logging.root.handlers) ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_update_alt_svc.py
test/mitmproxy/addons/test_update_alt_svc.py
from mitmproxy import http from mitmproxy.addons import update_alt_svc from mitmproxy.proxy.mode_specs import ProxyMode from mitmproxy.test import taddons from mitmproxy.test import tflow def test_simple(): header = 'h3="example.com:443"; ma=3600, h2=":443"; ma=3600' modified = update_alt_svc.update_alt_svc_h...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_export.py
test/mitmproxy/addons/test_export.py
import os import shlex from unittest import mock import pyperclip import pytest from mitmproxy import exceptions from mitmproxy.addons import export # heh from mitmproxy.test import taddons from mitmproxy.test import tflow from mitmproxy.test import tutils @pytest.fixture def get_request(): return tflow.tflow(...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_blocklist.py
test/mitmproxy/addons/test_blocklist.py
import pytest from mitmproxy.addons import blocklist from mitmproxy.exceptions import OptionsError from mitmproxy.test import taddons from mitmproxy.test import tflow @pytest.mark.parametrize( "filter,err", [ ("/~u index.html/TOOMANY/300", "Invalid number of parameters"), (":~d ~d ~d:200", "I...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_view.py
test/mitmproxy/addons/test_view.py
import pytest from mitmproxy import exceptions from mitmproxy import flowfilter from mitmproxy import io from mitmproxy.addons import view from mitmproxy.test import taddons from mitmproxy.test import tflow from mitmproxy.tools.console import consoleaddons from mitmproxy.tools.console.common import render_marker from ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_server_side_events.py
test/mitmproxy/addons/test_server_side_events.py
from mitmproxy.addons.server_side_events import ServerSideEvents from mitmproxy.test.tflow import tflow async def test_simple(caplog): s = ServerSideEvents() f = tflow(resp=True) f.response.headers["content-type"] = "text/event-stream" s.response(f) assert "mitmproxy currently does not support ser...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_save.py
test/mitmproxy/addons/test_save.py
import pytest from mitmproxy import exceptions from mitmproxy import io from mitmproxy.addons import save from mitmproxy.addons import view from mitmproxy.test import taddons from mitmproxy.test import tflow def test_configure(tmp_path): sa = save.Save() with taddons.context(sa) as tctx: with pytest....
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_next_layer.py
test/mitmproxy/addons/test_next_layer.py
from __future__ import annotations import dataclasses import logging from collections.abc import Sequence from dataclasses import dataclass from functools import partial from unittest.mock import MagicMock import pytest from mitmproxy.addons.next_layer import _starts_like_quic from mitmproxy.addons.next_layer import...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_asgiapp.py
test/mitmproxy/addons/test_asgiapp.py
import asyncio import json import flask from flask import request from mitmproxy.addons import asgiapp from mitmproxy.addons import next_layer from mitmproxy.addons.proxyserver import Proxyserver from mitmproxy.test import taddons tapp = flask.Flask(__name__) @tapp.route("/") def hello(): return "testapp" @t...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_block.py
test/mitmproxy/addons/test_block.py
import pytest from mitmproxy import connection from mitmproxy.addons import block from mitmproxy.proxy.mode_specs import ProxyMode from mitmproxy.test import taddons @pytest.mark.parametrize( "block_global, block_private, should_be_killed, address", [ # block_global: loopback (True, False, Fa...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_cut.py
test/mitmproxy/addons/test_cut.py
from unittest import mock import pyperclip import pytest from mitmproxy import certs from mitmproxy import exceptions from mitmproxy.addons import cut from mitmproxy.addons import view from mitmproxy.test import taddons from mitmproxy.test import tflow def test_extract(tdata): tf = tflow.tflow(resp=True) te...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_browser.py
test/mitmproxy/addons/test_browser.py
from unittest import mock from mitmproxy.addons import browser from mitmproxy.test import taddons def test_browser(caplog): caplog.set_level("INFO") with ( mock.patch("subprocess.Popen") as po, mock.patch("shutil.which") as which, taddons.context(), ): which.return_value =...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_serverplayback.py
test/mitmproxy/addons/test_serverplayback.py
import urllib import pytest import mitmproxy.test.tutils from mitmproxy import exceptions from mitmproxy import io from mitmproxy.addons import serverplayback from mitmproxy.test import taddons from mitmproxy.test import tflow def tdump(path, flows): with open(path, "wb") as f: w = io.FlowWriter(f) ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_dns_resolver.py
test/mitmproxy/addons/test_dns_resolver.py
import asyncio import socket import sys import typing import pytest import mitmproxy_rs from mitmproxy import dns from mitmproxy.addons import dns_resolver from mitmproxy.addons import proxyserver from mitmproxy.addons.dns_resolver import GetaddrinfoFallbackResolver from mitmproxy.proxy.mode_specs import ProxyMode fr...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_command_history.py
test/mitmproxy/addons/test_command_history.py
import os from pathlib import Path from unittest.mock import patch from mitmproxy.addons import command_history from mitmproxy.test import taddons class TestCommandHistory: def test_load_and_save(self, tmpdir): history_file = tmpdir.join("command_history") commands = ["cmd1", "cmd2", "cmd3"] ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_script.py
test/mitmproxy/addons/test_script.py
import asyncio import os import re import sys import traceback import pytest from mitmproxy import addonmanager from mitmproxy import exceptions from mitmproxy.addons import script from mitmproxy.proxy.layers.http import HttpRequestHook from mitmproxy.test import taddons from mitmproxy.test import tflow from mitmprox...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_clientplayback.py
test/mitmproxy/addons/test_clientplayback.py
import asyncio import ssl from contextlib import asynccontextmanager import pytest from mitmproxy.addons.clientplayback import ClientPlayback from mitmproxy.addons.clientplayback import ReplayHandler from mitmproxy.addons.proxyserver import Proxyserver from mitmproxy.addons.tlsconfig import TlsConfig from mitmproxy.c...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_comment.py
test/mitmproxy/addons/test_comment.py
from mitmproxy.addons.comment import Comment from mitmproxy.test import taddons from mitmproxy.test import tflow def test_comment(): c = Comment() f = tflow.tflow() with taddons.context(): c.comment([f], "foo") assert f.comment == "foo"
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_proxyserver.py
test/mitmproxy/addons/test_proxyserver.py
from __future__ import annotations import asyncio import ssl from collections.abc import AsyncGenerator from collections.abc import Callable from contextlib import asynccontextmanager from dataclasses import dataclass from typing import Any from typing import ClassVar from typing import TypeVar from unittest.mock impo...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_dumper.py
test/mitmproxy/addons/test_dumper.py
import io import shutil from unittest import mock import pytest import mitmproxy_rs.syntax_highlight from mitmproxy import exceptions from mitmproxy.addons import dumper from mitmproxy.addons.dumper import CONTENTVIEW_STYLES from mitmproxy.http import Headers from mitmproxy.net.dns import response_codes from mitmprox...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_proxyauth.py
test/mitmproxy/addons/test_proxyauth.py
import binascii from unittest import mock import ldap3 import pytest from mitmproxy import exceptions from mitmproxy.addons import proxyauth from mitmproxy.proxy.layers import modes from mitmproxy.proxy.mode_specs import ProxyMode from mitmproxy.test import taddons from mitmproxy.test import tflow @pytest.mark.para...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/__init__.py
test/mitmproxy/addons/__init__.py
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_intercept.py
test/mitmproxy/addons/test_intercept.py
import pytest from mitmproxy import exceptions from mitmproxy.addons import intercept from mitmproxy.test import taddons from mitmproxy.test import tflow async def test_simple(): r = intercept.Intercept() with taddons.context(r) as tctx: assert not r.filt tctx.configure(r, intercept="~q") ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_eventstore.py
test/mitmproxy/addons/test_eventstore.py
import asyncio import logging from mitmproxy.addons import eventstore async def test_simple(): store = eventstore.EventStore() assert not store.data sig_add_called = False sig_refresh_called = False def sig_add(entry): nonlocal sig_add_called sig_add_called = True def sig_r...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_anticache.py
test/mitmproxy/addons/test_anticache.py
from mitmproxy.addons import anticache from mitmproxy.test import taddons from mitmproxy.test import tflow class TestAntiCache: def test_simple(self): sa = anticache.AntiCache() with taddons.context(sa) as tctx: f = tflow.tflow(resp=True) f.request.headers["if-modified-sinc...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_readfile.py
test/mitmproxy/addons/test_readfile.py
import asyncio import io from unittest import mock import pytest import mitmproxy.io from mitmproxy import exceptions from mitmproxy.addons import readfile from mitmproxy.test import taddons from mitmproxy.test import tflow @pytest.fixture def data(): f = io.BytesIO() w = mitmproxy.io.FlowWriter(f) flo...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_disable_h2c.py
test/mitmproxy/addons/test_disable_h2c.py
from mitmproxy import flow from mitmproxy.addons import disable_h2c from mitmproxy.test import taddons from mitmproxy.test import tflow from mitmproxy.test import tutils class TestDisableH2CleartextUpgrade: def test_upgrade(self): with taddons.context() as tctx: a = disable_h2c.DisableH2C() ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_upstream_auth.py
test/mitmproxy/addons/test_upstream_auth.py
import base64 import pytest from mitmproxy import exceptions from mitmproxy.addons import upstream_auth from mitmproxy.proxy.mode_specs import ProxyMode from mitmproxy.test import taddons from mitmproxy.test import tflow def test_configure(): up = upstream_auth.UpstreamAuth() with taddons.context(up) as tct...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_stickycookie.py
test/mitmproxy/addons/test_stickycookie.py
import pytest from mitmproxy.addons import stickycookie from mitmproxy.test import taddons from mitmproxy.test import tflow from mitmproxy.test import tutils as ntutils def test_domain_match(): assert stickycookie.domain_match("www.google.com", ".google.com") assert stickycookie.domain_match("google.com", "....
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_keepserving.py
test/mitmproxy/addons/test_keepserving.py
import asyncio from mitmproxy import command from mitmproxy.addons import keepserving from mitmproxy.test import taddons class Dummy: def __init__(self, val: bool): self.val = val def load(self, loader): loader.add_option("client_replay", bool, self.val, "test") loader.add_option("se...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_modifyheaders.py
test/mitmproxy/addons/test_modifyheaders.py
import pytest from mitmproxy.addons.modifyheaders import ModifyHeaders from mitmproxy.addons.modifyheaders import parse_modify_spec from mitmproxy.test import taddons from mitmproxy.test import tflow from mitmproxy.test.tutils import tresp def test_parse_modify_spec(): spec = parse_modify_spec("/foo/bar/voing", ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_maplocal.py
test/mitmproxy/addons/test_maplocal.py
import sys from pathlib import Path import pytest from mitmproxy.addons.maplocal import file_candidates from mitmproxy.addons.maplocal import MapLocal from mitmproxy.addons.maplocal import MapLocalSpec from mitmproxy.test import taddons from mitmproxy.test import tflow from mitmproxy.utils.spec import parse_spec @p...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_stickyauth.py
test/mitmproxy/addons/test_stickyauth.py
import pytest from mitmproxy import exceptions from mitmproxy.addons import stickyauth from mitmproxy.test import taddons from mitmproxy.test import tflow def test_configure(): r = stickyauth.StickyAuth() with taddons.context(r) as tctx: tctx.configure(r, stickyauth="~s") with pytest.raises(e...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/addons/test_savehar.py
test/mitmproxy/addons/test_savehar.py
import json import zlib from pathlib import Path import pytest from mitmproxy import io from mitmproxy import types from mitmproxy import version from mitmproxy.addons.save import Save from mitmproxy.addons.savehar import SaveHar from mitmproxy.connection import Server from mitmproxy.exceptions import OptionsError fr...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/test_local_ip.py
test/mitmproxy/net/test_local_ip.py
from mitmproxy.net import local_ip def test_get_local_ip(): # should never error, but may return None depending on the host OS configuration. local_ip.get_local_ip() local_ip.get_local_ip("0.0.0.0") local_ip.get_local_ip("127.0.0.1") local_ip.get_local_ip("invalid!") def test_get_local_ip6(): ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/__init__.py
test/mitmproxy/net/__init__.py
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/test_check.py
test/mitmproxy/net/test_check.py
from mitmproxy.net import check def test_is_valid_host(): assert not check.is_valid_host(b"") assert not check.is_valid_host(b"xn--ke.ws") assert check.is_valid_host(b"one.two") assert not check.is_valid_host(b"one" * 255) assert check.is_valid_host(b"one.two.") # Allow underscore assert c...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/test_free_port.py
test/mitmproxy/net/test_free_port.py
import socket from mitmproxy.net import free_port def _raise(*_, **__): raise OSError def test_get_free_port(): assert free_port.get_free_port() is not None def test_never_raises(monkeypatch): monkeypatch.setattr(socket.socket, "bind", _raise) assert free_port.get_free_port() == 0
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/test_encoding.py
test/mitmproxy/net/test_encoding.py
from unittest import mock import pytest from mitmproxy.net import encoding @pytest.mark.parametrize( "encoder", [ "identity", "none", ], ) def test_identity(encoder): assert b"string" == encoding.decode(b"string", encoder) assert b"string" == encoding.encode(b"string", encoder) ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/test_tls.py
test/mitmproxy/net/test_tls.py
from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric import ec from OpenSSL import SSL from mitmproxy import certs from mitmproxy.net import tls @pytest.mark.parametrize("version", [tls.Version.UNBOUNDED, tls.Version.SSL3]) def test_supported(version): # wild assumption: test en...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/test_server_spec.py
test/mitmproxy/net/test_server_spec.py
import pytest from mitmproxy.net import server_spec @pytest.mark.parametrize( "spec,default_scheme,out", [ ("example.com", "https", ("https", ("example.com", 443))), ("http://example.com", "https", ("http", ("example.com", 80))), ("smtp.example.com:25", "tcp", ("tcp", ("smtp.example.c...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/dns/test_https_records.py
test/mitmproxy/net/dns/test_https_records.py
import re import struct import pytest from hypothesis import given from hypothesis import strategies as st from mitmproxy.net.dns import https_records class TestHTTPSRecords: def test_simple(self): assert https_records.SVCParamKeys.ALPN.value == 1 assert https_records.SVCParamKeys(1).name == "AL...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/dns/test_response_codes.py
test/mitmproxy/net/dns/test_response_codes.py
from mitmproxy.net.dns import response_codes def test_to_str(): assert response_codes.to_str(response_codes.NOERROR) == "NOERROR" assert response_codes.to_str(100) == "RCODE(100)" def test_from_str(): assert response_codes.from_str("NOERROR") == response_codes.NOERROR assert response_codes.from_str(...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/dns/test_domain_names.py
test/mitmproxy/net/dns/test_domain_names.py
import re import struct import pytest from mitmproxy.net.dns import domain_names from mitmproxy.net.dns import types def test_unpack_from_with_compression(): assert domain_names.unpack_from_with_compression( b"\xff\x03www\x07example\x03org\x00", 1, domain_names.cache() ) == ( "www.example.or...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/dns/test_classes.py
test/mitmproxy/net/dns/test_classes.py
from mitmproxy.net.dns import classes def test_to_str(): assert classes.to_str(classes.IN) == "IN" assert classes.to_str(0) == "CLASS(0)" def test_from_str(): assert classes.from_str("IN") == classes.IN assert classes.from_str("CLASS(0)") == 0
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/dns/test_types.py
test/mitmproxy/net/dns/test_types.py
from mitmproxy.net.dns import types def test_to_str(): assert types.to_str(types.A) == "A" assert types.to_str(0) == "TYPE(0)" def test_from_str(): assert types.from_str("A") == types.A assert types.from_str("TYPE(0)") == 0
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/dns/test_op_codes.py
test/mitmproxy/net/dns/test_op_codes.py
from mitmproxy.net.dns import op_codes def test_to_str(): assert op_codes.to_str(op_codes.QUERY) == "QUERY" assert op_codes.to_str(100) == "OPCODE(100)" def test_from_str(): assert op_codes.from_str("QUERY") == op_codes.QUERY assert op_codes.from_str("OPCODE(100)") == 100
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/dns/__init__.py
test/mitmproxy/net/dns/__init__.py
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/data/verificationcerts/generate.py
test/mitmproxy/net/data/verificationcerts/generate.py
""" Generate SSL test certificates. """ import os import shlex import shutil import subprocess import textwrap ROOT_CA = "trusted-root" SUBJECT = "example.mitmproxy.org" def do(args): print("> %s" % args) args = shlex.split(args) output = subprocess.check_output(args) return output def genrsa(cert...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/http/test_user_agents.py
test/mitmproxy/net/http/test_user_agents.py
from mitmproxy.net.http import user_agents def test_get_shortcut(): assert user_agents.get_by_shortcut("c")[0] == "chrome" assert not user_agents.get_by_shortcut("_")
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/http/test_cookies.py
test/mitmproxy/net/http/test_cookies.py
import time from unittest import mock import pytest from mitmproxy.net.http import cookies cookie_pairs = [ ["=uno", [["", "uno"]]], ["", []], ["one=uno", [["one", "uno"]]], ["one", [["one", ""]]], ["one=uno; two=due", [["one", "uno"], ["two", "due"]]], ['one="uno"; two="\\due"', [["one", "un...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/http/test_multipart.py
test/mitmproxy/net/http/test_multipart.py
import pytest from mitmproxy.net.http import multipart def test_decode(): boundary = "somefancyboundary" content = ( "--{0}\n" 'Content-Disposition: form-data; name="field1"\n\n' "value1\n" "--{0}\n" 'Content-Disposition: form-data; name="field2"\n\n' "value2\n...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/http/test_url.py
test/mitmproxy/net/http/test_url.py
from typing import AnyStr import pytest from mitmproxy.net.http import url from mitmproxy.net.http.url import parse_authority def test_parse(): with pytest.raises(ValueError): url.parse("") s, h, po, pa = url.parse(b"http://foo.com:8888/test") assert s == b"http" assert h == b"foo.com" ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/http/__init__.py
test/mitmproxy/net/http/__init__.py
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/http/test_validate.py
test/mitmproxy/net/http/test_validate.py
import pytest from mitmproxy.http import Headers from mitmproxy.http import Request from mitmproxy.http import Response from mitmproxy.net.http.validate import parse_content_length from mitmproxy.net.http.validate import parse_transfer_encoding from mitmproxy.net.http.validate import validate_headers def test_parse_...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/http/test_headers.py
test/mitmproxy/net/http/test_headers.py
import collections import pytest from mitmproxy.net.http.headers import assemble_content_type from mitmproxy.net.http.headers import infer_content_encoding from mitmproxy.net.http.headers import parse_content_type def test_parse_content_type(): p = parse_content_type assert p("text/html") == ("text", "html"...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/http/test_status_codes.py
test/mitmproxy/net/http/test_status_codes.py
from mitmproxy.net.http import status_codes def test_simple(): assert status_codes.IM_A_TEAPOT == 418 assert status_codes.RESPONSES[418] == "I'm a teapot"
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/http/http1/test_assemble.py
test/mitmproxy/net/http/http1/test_assemble.py
import pytest from mitmproxy.http import Headers from mitmproxy.net.http.http1.assemble import _assemble_request_headers from mitmproxy.net.http.http1.assemble import _assemble_request_line from mitmproxy.net.http.http1.assemble import _assemble_response_headers from mitmproxy.net.http.http1.assemble import assemble_b...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/http/http1/__init__.py
test/mitmproxy/net/http/http1/__init__.py
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/net/http/http1/test_read.py
test/mitmproxy/net/http/http1/test_read.py
import pytest from mitmproxy.http import Headers from mitmproxy.net.http.http1.read import _read_headers from mitmproxy.net.http.http1.read import _read_request_line from mitmproxy.net.http.http1.read import _read_response_line from mitmproxy.net.http.http1.read import connection_close from mitmproxy.net.http.http1.re...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/coretypes/test_multidict.py
test/mitmproxy/coretypes/test_multidict.py
import pytest from mitmproxy.coretypes import multidict class _TMulti: @staticmethod def _kconv(key): return key.lower() class TMultiDict(_TMulti, multidict.MultiDict): pass class TestMultiDict: @staticmethod def _multi(): return TMultiDict((("foo", "bar"), ("bar", "baz"), ("B...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/coretypes/test_serializable.py
test/mitmproxy/coretypes/test_serializable.py
from __future__ import annotations import copy import dataclasses import enum from collections.abc import Mapping from dataclasses import dataclass from typing import Literal import pytest from mitmproxy.coretypes import serializable from mitmproxy.coretypes.serializable import SerializableDataclass class Serializ...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/coretypes/test_bidi.py
test/mitmproxy/coretypes/test_bidi.py
import pytest from mitmproxy.coretypes import bidi def test_bidi(): b = bidi.BiDi(a=1, b=2) assert b.a == 1 assert b.get_name(1) == "a" assert b.get_name(5) is None with pytest.raises(AttributeError): getattr(b, "c") with pytest.raises(ValueError): bidi.BiDi(one=1, two=1)
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/coretypes/__init__.py
test/mitmproxy/coretypes/__init__.py
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_data.py
test/mitmproxy/utils/test_data.py
import pytest from mitmproxy.utils import data def test_pkg_data(): assert data.pkg_data.path("tools/console") with pytest.raises(ValueError): data.pkg_data.path("nonexistent")
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_bits.py
test/mitmproxy/utils/test_bits.py
# TODO: write tests
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false
mitmproxy/mitmproxy
https://github.com/mitmproxy/mitmproxy/blob/e6aa924bb411a9687b91920b8d094af37bc02b90/test/mitmproxy/utils/test_magisk.py
test/mitmproxy/utils/test_magisk.py
import os from cryptography import x509 from mitmproxy.test import taddons from mitmproxy.utils import magisk def test_get_ca(tdata): with taddons.context() as tctx: tctx.options.confdir = tdata.path("mitmproxy/data/confdir") ca = magisk.get_ca_from_files() assert isinstance(ca, x509.Cer...
python
MIT
e6aa924bb411a9687b91920b8d094af37bc02b90
2026-01-04T14:40:00.086164Z
false