File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88## Unreleased: mitmproxy next
99
10+ - Fix addon options not being included in ` --options ` output.
11+ ([ #4423 ] ( https://github.com/mitmproxy/mitmproxy/issues/4423 ) )
1012- Fix ` view.settings.setval.toggle ` command to correctly use the provided key parameter instead of hardcoded "key" string.
1113 ([ #8167 ] ( https://github.com/mitmproxy/mitmproxy/pull/8167 ) , @nameearly )
1214- Fix 400 Bad Request for HTTP requests with uppercase scheme (e.g. ` HTTP:// ` ).
Original file line number Diff line number Diff line change @@ -91,6 +91,11 @@ async def main() -> T:
9191 process_options (parser , opts , args )
9292
9393 if args .options :
94+ # Load custom addons so that their options are registered
95+ if sl := master .addons .get ("scriptloader" ):
96+ for s in sl .addons :
97+ if s .ns is None :
98+ s .loadscript ()
9499 optmanager .dump_defaults (opts , sys .stdout )
95100 sys .exit (0 )
96101 if args .commands :
Original file line number Diff line number Diff line change 1+ from typing import Optional
2+
3+
4+ class CustomOptionAddon :
5+ def load (self , loader ):
6+ loader .add_option (
7+ name = "custom_addon_option" ,
8+ typespec = Optional [int ],
9+ default = None ,
10+ help = "A custom option registered by an addon." ,
11+ )
12+
13+
14+ addons = [CustomOptionAddon ()]
Original file line number Diff line number Diff line change 1+ import pytest
2+
13from mitmproxy .tools import main
24
35shutdown_script = "mitmproxy/data/addonscripts/shutdown.py"
@@ -28,3 +30,26 @@ def test_mitmdump(tdata):
2830 "0" ,
2931 ]
3032 )
33+
34+
35+ def test_options_includes_addon_options (tdata , capsys ):
36+ """--options should include options registered by addon scripts."""
37+ with pytest .raises (SystemExit ):
38+ main .mitmdump (
39+ [
40+ "-s" ,
41+ tdata .path ("mitmproxy/data/addonscripts/custom_option.py" ),
42+ "--options" ,
43+ ]
44+ )
45+ output = capsys .readouterr ().out
46+ assert "custom_addon_option" in output
47+
48+
49+ def test_options_without_scripts (capsys ):
50+ """--options without any scripts should still work and list built-in options."""
51+ with pytest .raises (SystemExit ):
52+ main .mitmdump (["--options" ])
53+ output = capsys .readouterr ().out
54+ assert "listen_port" in output
55+ assert "custom_addon_option" not in output
You can’t perform that action at this time.
0 commit comments