aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2019-11-19 18:15:08 +0100
committerGitHub <noreply@github.com>2019-11-19 18:15:08 +0100
commite92b957e3a7324d79f2ef2a7386ed21549a5cb10 (patch)
tree4bb4bc4e0abcfb88ddf0004df4edef4b51ce0091 /test
parent70e3871fdb066fa4267cfb44df36e24f9986e3e7 (diff)
downloadmitmproxy-e92b957e3a7324d79f2ef2a7386ed21549a5cb10.tar.gz
mitmproxy-e92b957e3a7324d79f2ef2a7386ed21549a5cb10.tar.bz2
mitmproxy-e92b957e3a7324d79f2ef2a7386ed21549a5cb10.zip
Use Github Actions for CI (#3713)
switch to github actions for CI
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/contentviews/test_protobuf.py6
-rw-r--r--test/mitmproxy/contentviews/test_protobuf_data/protobuf01.bin (renamed from test/mitmproxy/contentviews/test_protobuf_data/protobuf01)0
-rw-r--r--test/mitmproxy/contentviews/test_protobuf_data/protobuf02-decoded.bin (renamed from test/mitmproxy/contentviews/test_protobuf_data/protobuf02-decoded)0
-rw-r--r--test/mitmproxy/contentviews/test_protobuf_data/protobuf02.bin (renamed from test/mitmproxy/contentviews/test_protobuf_data/protobuf02)bin213 -> 213 bytes
-rw-r--r--test/mitmproxy/contentviews/test_protobuf_data/protobuf03-decoded.bin (renamed from test/mitmproxy/contentviews/test_protobuf_data/protobuf03-decoded)0
-rw-r--r--test/mitmproxy/contentviews/test_protobuf_data/protobuf03.bin (renamed from test/mitmproxy/contentviews/test_protobuf_data/protobuf03)0
-rw-r--r--test/mitmproxy/data/dumpfile-010.bin (renamed from test/mitmproxy/data/dumpfile-010)bin2140 -> 2140 bytes
-rw-r--r--test/mitmproxy/data/dumpfile-011.bin (renamed from test/mitmproxy/data/dumpfile-011)0
-rw-r--r--test/mitmproxy/data/dumpfile-018.bin (renamed from test/mitmproxy/data/dumpfile-018)0
-rw-r--r--test/mitmproxy/io/test_compat.py6
-rw-r--r--test/mitmproxy/proxy/test_config.py2
-rw-r--r--test/mitmproxy/test_proxy.py15
-rw-r--r--test/release/test_cibuild.py64
13 files changed, 68 insertions, 25 deletions
diff --git a/test/mitmproxy/contentviews/test_protobuf.py b/test/mitmproxy/contentviews/test_protobuf.py
index 791045e7..f0a91fd1 100644
--- a/test/mitmproxy/contentviews/test_protobuf.py
+++ b/test/mitmproxy/contentviews/test_protobuf.py
@@ -8,7 +8,7 @@ datadir = "mitmproxy/contentviews/test_protobuf_data/"
def test_view_protobuf_request(tdata):
v = full_eval(protobuf.ViewProtobuf())
- p = tdata.path(datadir + "protobuf01")
+ p = tdata.path(datadir + "protobuf01.bin")
with open(p, "rb") as f:
raw = f.read()
@@ -19,12 +19,12 @@ def test_view_protobuf_request(tdata):
v(b'foobar')
-@pytest.mark.parametrize("filename", ["protobuf02", "protobuf03"])
+@pytest.mark.parametrize("filename", ["protobuf02.bin", "protobuf03.bin"])
def test_format_pbuf(filename, tdata):
path = tdata.path(datadir + filename)
with open(path, "rb") as f:
input = f.read()
- with open(path + "-decoded") as f:
+ with open(path.replace(".bin", "-decoded.bin")) as f:
expected = f.read()
assert protobuf.format_pbuf(input) == expected
diff --git a/test/mitmproxy/contentviews/test_protobuf_data/protobuf01 b/test/mitmproxy/contentviews/test_protobuf_data/protobuf01.bin
index fbfdbff3..fbfdbff3 100644
--- a/test/mitmproxy/contentviews/test_protobuf_data/protobuf01
+++ b/test/mitmproxy/contentviews/test_protobuf_data/protobuf01.bin
diff --git a/test/mitmproxy/contentviews/test_protobuf_data/protobuf02-decoded b/test/mitmproxy/contentviews/test_protobuf_data/protobuf02-decoded.bin
index 9be61e28..9be61e28 100644
--- a/test/mitmproxy/contentviews/test_protobuf_data/protobuf02-decoded
+++ b/test/mitmproxy/contentviews/test_protobuf_data/protobuf02-decoded.bin
diff --git a/test/mitmproxy/contentviews/test_protobuf_data/protobuf02 b/test/mitmproxy/contentviews/test_protobuf_data/protobuf02.bin
index a47c45d5..a47c45d5 100644
--- a/test/mitmproxy/contentviews/test_protobuf_data/protobuf02
+++ b/test/mitmproxy/contentviews/test_protobuf_data/protobuf02.bin
Binary files differ
diff --git a/test/mitmproxy/contentviews/test_protobuf_data/protobuf03-decoded b/test/mitmproxy/contentviews/test_protobuf_data/protobuf03-decoded.bin
index 3d3392e1..3d3392e1 100644
--- a/test/mitmproxy/contentviews/test_protobuf_data/protobuf03-decoded
+++ b/test/mitmproxy/contentviews/test_protobuf_data/protobuf03-decoded.bin
diff --git a/test/mitmproxy/contentviews/test_protobuf_data/protobuf03 b/test/mitmproxy/contentviews/test_protobuf_data/protobuf03.bin
index 9fb230b3..9fb230b3 100644
--- a/test/mitmproxy/contentviews/test_protobuf_data/protobuf03
+++ b/test/mitmproxy/contentviews/test_protobuf_data/protobuf03.bin
diff --git a/test/mitmproxy/data/dumpfile-010 b/test/mitmproxy/data/dumpfile-010.bin
index 435795bf..435795bf 100644
--- a/test/mitmproxy/data/dumpfile-010
+++ b/test/mitmproxy/data/dumpfile-010.bin
Binary files differ
diff --git a/test/mitmproxy/data/dumpfile-011 b/test/mitmproxy/data/dumpfile-011.bin
index 936ac0cc..936ac0cc 100644
--- a/test/mitmproxy/data/dumpfile-011
+++ b/test/mitmproxy/data/dumpfile-011.bin
diff --git a/test/mitmproxy/data/dumpfile-018 b/test/mitmproxy/data/dumpfile-018.bin
index 6a27b5a6..6a27b5a6 100644
--- a/test/mitmproxy/data/dumpfile-018
+++ b/test/mitmproxy/data/dumpfile-018.bin
diff --git a/test/mitmproxy/io/test_compat.py b/test/mitmproxy/io/test_compat.py
index 4c31e363..341906ca 100644
--- a/test/mitmproxy/io/test_compat.py
+++ b/test/mitmproxy/io/test_compat.py
@@ -5,7 +5,7 @@ from mitmproxy import exceptions
def test_load(tdata):
- with open(tdata.path("mitmproxy/data/dumpfile-011"), "rb") as f:
+ with open(tdata.path("mitmproxy/data/dumpfile-011.bin"), "rb") as f:
flow_reader = io.FlowReader(f)
flows = list(flow_reader.stream())
assert len(flows) == 1
@@ -13,7 +13,7 @@ def test_load(tdata):
def test_load_018(tdata):
- with open(tdata.path("mitmproxy/data/dumpfile-018"), "rb") as f:
+ with open(tdata.path("mitmproxy/data/dumpfile-018.bin"), "rb") as f:
flow_reader = io.FlowReader(f)
flows = list(flow_reader.stream())
assert len(flows) == 1
@@ -21,7 +21,7 @@ def test_load_018(tdata):
def test_cannot_convert(tdata):
- with open(tdata.path("mitmproxy/data/dumpfile-010"), "rb") as f:
+ with open(tdata.path("mitmproxy/data/dumpfile-010.bin"), "rb") as f:
flow_reader = io.FlowReader(f)
with pytest.raises(exceptions.FlowReadException):
list(flow_reader.stream())
diff --git a/test/mitmproxy/proxy/test_config.py b/test/mitmproxy/proxy/test_config.py
index 1319d1a9..38a6e1ad 100644
--- a/test/mitmproxy/proxy/test_config.py
+++ b/test/mitmproxy/proxy/test_config.py
@@ -14,7 +14,7 @@ class TestProxyConfig:
def test_invalid_certificate(self, tdata):
opts = options.Options()
- opts.certs = [tdata.path("mitmproxy/data/dumpfile-011")]
+ opts.certs = [tdata.path("mitmproxy/data/dumpfile-011.bin")]
with pytest.raises(exceptions.OptionsError, match="Invalid certificate format"):
ProxyConfig(opts)
diff --git a/test/mitmproxy/test_proxy.py b/test/mitmproxy/test_proxy.py
index c8cf6c33..f455b0ff 100644
--- a/test/mitmproxy/test_proxy.py
+++ b/test/mitmproxy/test_proxy.py
@@ -1,20 +1,19 @@
import argparse
import platform
from unittest import mock
+
import pytest
-from mitmproxy.tools import cmdline
-from mitmproxy.tools import main
from mitmproxy import options
from mitmproxy.proxy import ProxyConfig
-from mitmproxy.proxy.server import DummyServer, ProxyServer, ConnectionHandler
from mitmproxy.proxy import config
-
+from mitmproxy.proxy.server import ConnectionHandler, DummyServer, ProxyServer
+from mitmproxy.tools import cmdline
+from mitmproxy.tools import main
from ..conftest import skip_windows
class MockParser(argparse.ArgumentParser):
-
"""
argparse.ArgumentParser sys.exits() by default.
Make it more testable by throwing an exception instead.
@@ -53,11 +52,9 @@ class TestProcessProxyOptions:
class TestProxyServer:
@skip_windows
- @pytest.mark.skipif(platform.mac_ver()[0].split('.')[:2] == ['10', '14'],
- reason='Skipping due to macOS Mojave')
+ @pytest.mark.skipif(platform.system() != "Linux", reason="Linux-only")
def test_err(self):
- # binding to 0.0.0.0:1 works without special permissions on Windows and
- # macOS Mojave
+ # binding to 0.0.0.0:1 works without special permissions on Windows and macOS Mojave+
conf = ProxyConfig(options.Options(listen_port=1))
with pytest.raises(Exception, match="Error starting proxy server"):
ProxyServer(conf)
diff --git a/test/release/test_cibuild.py b/test/release/test_cibuild.py
index cfa24e63..d4ed32b0 100644
--- a/test/release/test_cibuild.py
+++ b/test/release/test_cibuild.py
@@ -58,31 +58,60 @@ def test_buildenviron_pr():
)
assert be.is_pull_request
- # Mini test for appveyor
- be = cibuild.BuildEnviron(
- appveyor_pull_request_number="xxxx",
+
+def test_ci_systems():
+ appveyor = cibuild.BuildEnviron(
+ appveyor_pull_request_number="1234",
+ appveyor_repo_branch="foo",
+ appveyor_repo_tag_name="qux",
)
- assert be.is_pull_request
- assert not be.is_prod_release
- assert not be.is_maintenance_branch
+ assert appveyor.is_pull_request
+ assert appveyor.branch == "foo"
+ assert appveyor.tag == "qux"
+
+ travis = cibuild.BuildEnviron(
+ travis_pull_request="1234",
+ travis_branch="foo",
+ travis_tag="foo",
+ )
+ assert travis.is_pull_request
+ assert travis.branch == "foo"
+ assert travis.tag == "foo"
+
+ github = cibuild.BuildEnviron(
+ github_event_name="pull_request",
+ github_ref="refs/heads/master"
+ )
+ assert github.is_pull_request
+ assert github.branch == "master"
+ assert github.tag == ""
+
+ github2 = cibuild.BuildEnviron(
+ github_event_name="pull_request",
+ github_ref="refs/tags/qux"
+ )
+ assert github2.is_pull_request
+ assert github2.branch == ""
+ assert github2.tag == "qux"
def test_buildenviron_commit():
# Simulates an ordinary commit on the master branch.
be = cibuild.BuildEnviron(
- travis_tag="",
- travis_branch="master",
- travis_pull_request="false",
+ github_ref="refs/heads/master",
+ github_event_name="push",
should_build_wheel=True,
should_build_pyinstaller=True,
should_build_docker=True,
docker_username="foo",
docker_password="bar",
+ has_aws_creds=True,
)
assert be.docker_tag == "mitmproxy/mitmproxy:dev"
assert be.should_upload_docker
assert not be.should_upload_pypi
assert be.should_upload_docker
+ assert be.should_upload_aws
assert not be.is_prod_release
assert not be.is_maintenance_branch
@@ -244,3 +273,20 @@ def test_buildenviron_check_version(version, tag, ok, tmpdir):
else:
with pytest.raises(ValueError):
be.check_version()
+
+
+def test_bool_from_env(monkeypatch):
+ monkeypatch.setenv("FOO", "1")
+ assert cibuild.bool_from_env("FOO")
+
+ monkeypatch.setenv("FOO", "0")
+ assert not cibuild.bool_from_env("FOO")
+
+ monkeypatch.setenv("FOO", "false")
+ assert not cibuild.bool_from_env("FOO")
+
+ monkeypatch.setenv("FOO", "")
+ assert not cibuild.bool_from_env("FOO")
+
+ monkeypatch.delenv("FOO")
+ assert not cibuild.bool_from_env("FOO")