diff options
-rw-r--r-- | .appveyor.yml | 18 | ||||
-rw-r--r-- | mitmproxy/master.py | 8 | ||||
-rw-r--r-- | setup.cfg | 2 | ||||
-rw-r--r-- | setup.py | 4 | ||||
-rw-r--r-- | test/mitmproxy/test_flow.py | 16 | ||||
-rw-r--r-- | test/mitmproxy/test_http.py | 17 |
6 files changed, 46 insertions, 19 deletions
diff --git a/.appveyor.yml b/.appveyor.yml index 549a0607..909a9149 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -44,22 +44,28 @@ test_script: ($Env:TOXENV -match "py35") -and !$Env:APPVEYOR_PULL_REQUEST_NUMBER -and (($Env:APPVEYOR_REPO_BRANCH -In ("master", "pyinstaller")) -or ($Env:APPVEYOR_REPO_TAG -match "true")) ) { + echo "Decrypt license..." tox -e rtool -- decrypt release\installbuilder\license.xml.enc release\installbuilder\license.xml - if (!(Test-Path "C:\projects\mitmproxy\release\installbuilder-installer.exe")) { - "Download InstallBuilder..." + $ibSetup = "C:\projects\mitmproxy\release\installbuilder-installer.exe" + $ibVersion = "17.4.0" + if (!(Test-Path $ibSetup)) { + echo "Download InstallBuilder..." (New-Object System.Net.WebClient).DownloadFile( - "https://installbuilder.bitrock.com/installbuilder-enterprise-17.1.0-windows-installer.exe", - "C:\projects\mitmproxy\release\installbuilder-installer.exe" + "https://installbuilder.bitrock.com/installbuilder-enterprise-$ibVersion-windows-installer.exe", + $ibSetup ) } - Start-Process "C:\projects\mitmproxy\release\installbuilder-installer.exe" "--mode unattended --unattendedmodeui none" -Wait - & 'C:\Program Files (x86)\BitRock InstallBuilder Enterprise 17.1.0\bin\builder-cli.exe' ` + echo "Install InstallBuilder..." + Start-Process $ibSetup "--mode unattended --unattendedmodeui none" -Wait + echo "Run InstallBuilder..." + & "C:\Program Files (x86)\BitRock InstallBuilder Enterprise $ibVersion\bin\builder-cli.exe" ` build ` .\release\installbuilder\mitmproxy.xml ` windows ` --license .\release\installbuilder\license.xml ` --setvars project.version=$Env:VERSION ` --verbose + echo "Installer build completed." } deploy_script: diff --git a/mitmproxy/master.py b/mitmproxy/master.py index d21a323e..b17f7e5d 100644 --- a/mitmproxy/master.py +++ b/mitmproxy/master.py @@ -147,14 +147,14 @@ class Master: raise exceptions.ReplayException( "Can't replay intercepted flow." ) - if f.request.raw_content is None: - raise exceptions.ReplayException( - "Can't replay flow with missing content." - ) if not f.request: raise exceptions.ReplayException( "Can't replay flow with missing request." ) + if f.request.raw_content is None: + raise exceptions.ReplayException( + "Can't replay flow with missing content." + ) f.backup() f.request.is_replay = True @@ -26,8 +26,6 @@ exclude = mitmproxy/proxy/root_context.py mitmproxy/proxy/server.py mitmproxy/tools/ - mitmproxy/flow.py - mitmproxy/master.py pathod/pathoc.py pathod/pathod.py pathod/test.py @@ -61,10 +61,10 @@ setup( # It is not considered best practice to use install_requires to pin dependencies to specific versions. install_requires=[ "blinker>=1.4, <1.5", - "brotlipy>=0.5.1, <0.7", + "brotlipy>=0.5.1, <0.8", "certifi>=2015.11.20.1", # no semver here - this should always be on the last release! "click>=6.2, <7", - "cryptography>=1.4, <1.9", + "cryptography>=1.4, <1.10", "cssutils>=1.0.1, <1.1", "h2>=3.0, <4", "html2text>=2016.1.8, <=2016.9.19", diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py index 19f0e7d9..9f6ed585 100644 --- a/test/mitmproxy/test_flow.py +++ b/test/mitmproxy/test_flow.py @@ -7,7 +7,7 @@ from mitmproxy import flowfilter from mitmproxy import options from mitmproxy.proxy import config from mitmproxy.io import tnetstring -from mitmproxy.exceptions import FlowReadException +from mitmproxy.exceptions import FlowReadException, ReplayException, ControlException from mitmproxy import flow from mitmproxy import http from mitmproxy.proxy.server import DummyServer @@ -102,15 +102,19 @@ class TestFlowMaster: fm = master.Master(None, DummyServer()) f = tflow.tflow(resp=True) f.request.content = None - with pytest.raises(Exception, match="missing"): + with pytest.raises(ReplayException, match="missing"): + fm.replay_request(f) + + f.request = None + with pytest.raises(ReplayException, match="request"): fm.replay_request(f) f.intercepted = True - with pytest.raises(Exception, match="intercepted"): + with pytest.raises(ReplayException, match="intercepted"): fm.replay_request(f) f.live = True - with pytest.raises(Exception, match="live"): + with pytest.raises(ReplayException, match="live"): fm.replay_request(f) def test_all(self): @@ -132,6 +136,10 @@ class TestFlowMaster: f.error = flow.Error("msg") fm.addons.handle_lifecycle("error", f) + fm.tell("foo", f) + with pytest.raises(ControlException): + fm.tick(timeout=1) + fm.shutdown() diff --git a/test/mitmproxy/test_http.py b/test/mitmproxy/test_http.py index aa283530..4463961a 100644 --- a/test/mitmproxy/test_http.py +++ b/test/mitmproxy/test_http.py @@ -4,7 +4,7 @@ from mitmproxy.test import tflow from mitmproxy.net.http import Headers import mitmproxy.io from mitmproxy import flowfilter -from mitmproxy.exceptions import Kill +from mitmproxy.exceptions import Kill, ControlException from mitmproxy import flow from mitmproxy import http @@ -170,17 +170,32 @@ class TestHTTPFlow: assert not f == f2 f2.error = flow.Error("e2") assert not f == f2 + f2.backup() + f2.intercept() # to change the state f.set_state(f2.get_state()) assert f.get_state() == f2.get_state() def test_kill(self): f = tflow.tflow() + with pytest.raises(ControlException): + f.intercept() + f.resume() + f.kill() + + f = tflow.tflow() f.intercept() assert f.killable f.kill() assert not f.killable assert f.reply.value == Kill + def test_intercept(self): + f = tflow.tflow() + f.intercept() + assert f.reply.state == "taken" + f.intercept() + assert f.reply.state == "taken" + def test_resume(self): f = tflow.tflow() f.intercept() |