mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +00:00
Merge branch 'master' into beautiful-json
This commit is contained in:
commit
db11fe0087
@ -13,11 +13,13 @@ environment:
|
|||||||
SNAPSHOT_PASS:
|
SNAPSHOT_PASS:
|
||||||
secure: LPjrtFrWxYhOVGXzfPRV1GjtZE/wHoKq9m/PI6hSalfysUK5p2DxTG9uHlb4Q9qV
|
secure: LPjrtFrWxYhOVGXzfPRV1GjtZE/wHoKq9m/PI6hSalfysUK5p2DxTG9uHlb4Q9qV
|
||||||
install:
|
install:
|
||||||
- "pip install --user -U virtualenv"
|
- "pip install --user -U virtualenv codecov"
|
||||||
- "dev.bat"
|
- "dev.bat"
|
||||||
- "python -c \"from OpenSSL import SSL; print(SSL.SSLeay_version(SSL.SSLEAY_VERSION))\""
|
- "python -c \"from OpenSSL import SSL; print(SSL.SSLeay_version(SSL.SSLEAY_VERSION))\""
|
||||||
test_script:
|
test_script:
|
||||||
- "py.test --timeout 60 --cov netlib --cov mitmproxy --cov pathod"
|
- "py.test --timeout 60 --cov netlib --cov mitmproxy --cov pathod"
|
||||||
|
after_test:
|
||||||
|
- "codecov"
|
||||||
cache:
|
cache:
|
||||||
- C:\Users\appveyor\AppData\Local\pip\cache
|
- C:\Users\appveyor\AppData\Local\pip\cache
|
||||||
deploy_script:
|
deploy_script:
|
||||||
|
33
.travis.yml
33
.travis.yml
@ -14,20 +14,21 @@ matrix:
|
|||||||
fast_finish: true
|
fast_finish: true
|
||||||
include:
|
include:
|
||||||
- python: 2.7
|
- python: 2.7
|
||||||
|
env: TOXENV=py27
|
||||||
- python: 2.7
|
- python: 2.7
|
||||||
env: NO_ALPN=1
|
env: TOXENV=py27 NO_ALPN=1
|
||||||
|
- python: 3.5
|
||||||
|
env: TOXENV=py35
|
||||||
|
- python: 3.5
|
||||||
|
env: TOXENV=py35 NO_ALPN=1
|
||||||
- language: generic
|
- language: generic
|
||||||
|
env: TOXENV=py27
|
||||||
os: osx
|
os: osx
|
||||||
osx_image: xcode7.1
|
osx_image: xcode7.1
|
||||||
git:
|
git:
|
||||||
depth: 9999999
|
depth: 9999999
|
||||||
- python: 3.5
|
|
||||||
env: SCOPE="netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_base.py test/pathod/test_language_http.py"
|
|
||||||
- python: 3.5
|
|
||||||
env: SCOPE="netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_base.py test/pathod/test_language_http.py" NO_ALPN=1
|
|
||||||
- python: 2.7
|
- python: 2.7
|
||||||
env: DOCS=1
|
env: TOXENV=docs
|
||||||
script: 'cd docs && SPHINXOPTS="-W" make -e html'
|
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- python: pypy
|
- python: pypy
|
||||||
|
|
||||||
@ -39,23 +40,20 @@ install:
|
|||||||
brew outdated openssl || brew upgrade openssl
|
brew outdated openssl || brew upgrade openssl
|
||||||
brew install python
|
brew install python
|
||||||
fi
|
fi
|
||||||
- pip install -U virtualenv
|
|
||||||
- ./dev.sh
|
|
||||||
- source venv/bin/activate
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- "openssl version -a"
|
- "pip install tox"
|
||||||
- "python -c \"from OpenSSL import SSL; print(SSL.SSLeay_version(SSL.SSLEAY_VERSION))\""
|
- "tox -e lint"
|
||||||
- "flake8 --jobs 4 --count mitmproxy netlib pathod examples test"
|
|
||||||
|
|
||||||
script:
|
script: tox
|
||||||
- "py.test --timeout 60 --cov netlib --cov mitmproxy --cov pathod test/$SCOPE"
|
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- coveralls
|
|
||||||
- |
|
- |
|
||||||
if [[ $TRAVIS_OS_NAME == "osx" && $TRAVIS_PULL_REQUEST == "false" && ($TRAVIS_BRANCH == "master" || -n $TRAVIS_TAG) ]]
|
if [[ $TRAVIS_OS_NAME == "osx" && $TRAVIS_PULL_REQUEST == "false" && ($TRAVIS_BRANCH == "master" || -n $TRAVIS_TAG) ]]
|
||||||
then
|
then
|
||||||
|
pip install -U virtualenv
|
||||||
|
./dev.sh
|
||||||
|
source venv/bin/activate
|
||||||
pip install -e ./release
|
pip install -e ./release
|
||||||
python ./release/rtool.py bdist
|
python ./release/rtool.py bdist
|
||||||
python ./release/rtool.py upload-snapshot --bdist --wheel
|
python ./release/rtool.py upload-snapshot --bdist --wheel
|
||||||
@ -71,7 +69,6 @@ notifications:
|
|||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- $HOME/build/mitmproxy/mitmproxy/venv
|
- $HOME/build/mitmproxy/mitmproxy/.tox
|
||||||
- $HOME/.cache/pip
|
- $HOME/.cache/pip
|
||||||
- $HOME/.pyenv
|
- $HOME/.pyenv
|
||||||
- $HOME/Library/Caches/pip
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
mitmproxy
|
mitmproxy
|
||||||
^^^^^^^^^
|
^^^^^^^^^
|
||||||
|
|
||||||
|travis| |coveralls| |latest_release| |python_versions|
|
|travis| |coverage| |latest_release| |python_versions|
|
||||||
|
|
||||||
This repository contains the **mitmproxy** and **pathod** projects, as well as
|
This repository contains the **mitmproxy** and **pathod** projects, as well as
|
||||||
their shared networking library, **netlib**.
|
their shared networking library, **netlib**.
|
||||||
@ -141,8 +141,8 @@ good reason not to.
|
|||||||
:target: https://travis-ci.org/mitmproxy/mitmproxy
|
:target: https://travis-ci.org/mitmproxy/mitmproxy
|
||||||
:alt: Build Status
|
:alt: Build Status
|
||||||
|
|
||||||
.. |coveralls| image:: https://shields.mitmproxy.org/coveralls/mitmproxy/mitmproxy/master.svg
|
.. |coverage| image:: https://codecov.io/gh/mitmproxy/mitmproxy/branch/master/graph/badge.svg
|
||||||
:target: https://coveralls.io/r/mitmproxy/mitmproxy
|
:target: https://codecov.io/gh/mitmproxy/mitmproxy
|
||||||
:alt: Coverage Status
|
:alt: Coverage Status
|
||||||
|
|
||||||
.. |latest_release| image:: https://shields.mitmproxy.org/pypi/v/mitmproxy.svg
|
.. |latest_release| image:: https://shields.mitmproxy.org/pypi/v/mitmproxy.svg
|
||||||
|
1
codecov.yml
Normal file
1
codecov.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
comment: off
|
@ -120,13 +120,7 @@ def isMostlyBin(s):
|
|||||||
|
|
||||||
|
|
||||||
def isXML(s):
|
def isXML(s):
|
||||||
for i in s:
|
return s.strip().startswith("<")
|
||||||
if i in "\n \t":
|
|
||||||
continue
|
|
||||||
elif i == "<":
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def clean_hanging_newline(t):
|
def clean_hanging_newline(t):
|
||||||
|
3
setup.py
3
setup.py
@ -97,9 +97,8 @@ setup(
|
|||||||
"ipaddress>=1.0.15, <1.1",
|
"ipaddress>=1.0.15, <1.1",
|
||||||
],
|
],
|
||||||
'dev': [
|
'dev': [
|
||||||
"coveralls>=1.1, <1.2",
|
"tox>=2.3, <3",
|
||||||
"mock>=2.0, <2.1",
|
"mock>=2.0, <2.1",
|
||||||
"flake8>=2.5.4, <3",
|
|
||||||
"pytest>=2.8.7, <2.10",
|
"pytest>=2.8.7, <2.10",
|
||||||
"pytest-cov>=2.2.1, <2.3",
|
"pytest-cov>=2.2.1, <2.3",
|
||||||
"pytest-timeout>=1.0.0, <1.1",
|
"pytest-timeout>=1.0.0, <1.1",
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
import six
|
||||||
|
|
||||||
from netlib import strutils
|
from netlib import strutils, tutils
|
||||||
|
|
||||||
|
|
||||||
|
def test_native():
|
||||||
|
with tutils.raises(TypeError):
|
||||||
|
strutils.native(42)
|
||||||
|
if six.PY2:
|
||||||
|
assert strutils.native(u"foo") == b"foo"
|
||||||
|
assert strutils.native(b"foo") == b"foo"
|
||||||
|
else:
|
||||||
|
assert strutils.native(u"foo") == u"foo"
|
||||||
|
assert strutils.native(b"foo") == u"foo"
|
||||||
|
|
||||||
|
|
||||||
def test_clean_bin():
|
def test_clean_bin():
|
||||||
@ -29,6 +41,9 @@ def test_bytes_to_escaped_str():
|
|||||||
assert strutils.bytes_to_escaped_str(b"'") == r"\'"
|
assert strutils.bytes_to_escaped_str(b"'") == r"\'"
|
||||||
assert strutils.bytes_to_escaped_str(b'"') == r'"'
|
assert strutils.bytes_to_escaped_str(b'"') == r'"'
|
||||||
|
|
||||||
|
with tutils.raises(ValueError):
|
||||||
|
strutils.bytes_to_escaped_str(u"such unicode")
|
||||||
|
|
||||||
|
|
||||||
def test_escaped_str_to_bytes():
|
def test_escaped_str_to_bytes():
|
||||||
assert strutils.escaped_str_to_bytes("foo") == b"foo"
|
assert strutils.escaped_str_to_bytes("foo") == b"foo"
|
||||||
@ -39,6 +54,13 @@ def test_escaped_str_to_bytes():
|
|||||||
assert strutils.escaped_str_to_bytes(u"&!?=\\\\)") == br"&!?=\)"
|
assert strutils.escaped_str_to_bytes(u"&!?=\\\\)") == br"&!?=\)"
|
||||||
assert strutils.escaped_str_to_bytes(u"ü") == b'\xc3\xbc'
|
assert strutils.escaped_str_to_bytes(u"ü") == b'\xc3\xbc'
|
||||||
|
|
||||||
|
if six.PY2:
|
||||||
|
with tutils.raises(ValueError):
|
||||||
|
strutils.escaped_str_to_bytes(42)
|
||||||
|
else:
|
||||||
|
with tutils.raises(ValueError):
|
||||||
|
strutils.escaped_str_to_bytes(b"very byte")
|
||||||
|
|
||||||
|
|
||||||
def test_isBin():
|
def test_isBin():
|
||||||
assert not strutils.isBin("testing\n\r")
|
assert not strutils.isBin("testing\n\r")
|
||||||
|
@ -87,4 +87,4 @@ def test_write_values_after():
|
|||||||
s = BytesIO()
|
s = BytesIO()
|
||||||
r = next(language.parse_pathod("400:ia,'xx'"))
|
r = next(language.parse_pathod("400:ia,'xx'"))
|
||||||
language.serve(r, s, {})
|
language.serve(r, s, {})
|
||||||
assert s.getvalue().endswith('xx')
|
assert s.getvalue().endswith(b'xx')
|
||||||
|
28
tox.ini
28
tox.ini
@ -1,15 +1,31 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py27, py35, lint
|
envlist = py27, py35, docs, lint
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps = -rrequirements.txt
|
deps =
|
||||||
|
-rrequirements.txt
|
||||||
|
codecov>=2.0.5
|
||||||
|
passenv = CI TRAVIS_BUILD_ID TRAVIS TRAVIS_BRANCH TRAVIS_JOB_NUMBER TRAVIS_PULL_REQUEST TRAVIS_JOB_ID TRAVIS_REPO_SLUG TRAVIS_COMMIT
|
||||||
|
|
||||||
[testenv:py27]
|
[testenv:py27]
|
||||||
commands = py.test -n 8 --timeout 60 ./test
|
commands =
|
||||||
|
py.test --cov netlib --cov mitmproxy --cov pathod --color=yes --timeout 60 ./test
|
||||||
|
codecov -e TOXENV
|
||||||
|
|
||||||
[testenv:py35]
|
[testenv:py35]
|
||||||
commands = py.test -n 8 --timeout 60 test/netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_writer.py test/pathod/test_language_base.py test/pathod/test_language_http.py
|
# remove bash & pipe & grep hack after cryptography ships with openssl 1.1.0
|
||||||
|
whitelist_externals = bash
|
||||||
|
commands =
|
||||||
|
bash -c 'py.test --cov netlib --cov mitmproxy --cov pathod --color=yes --timeout 60 test/netlib test/mitmproxy/script test/pathod/test_utils.py test/pathod/test_log.py test/pathod/test_language_generators.py test/pathod/test_language_writer.py test/pathod/test_language_base.py test/pathod/test_language_http.py test/pathod/test_language_websocket.py 2>&1 | grep -v Cryptography_locking_cb'
|
||||||
|
codecov -e TOXENV
|
||||||
|
|
||||||
|
[testenv:docs]
|
||||||
|
basepython = python2.7
|
||||||
|
whitelist_externals = make
|
||||||
|
changedir = docs
|
||||||
|
setenv = SPHINXOPTS="-W"
|
||||||
|
commands = make -e html
|
||||||
|
|
||||||
[testenv:lint]
|
[testenv:lint]
|
||||||
deps = flake8
|
deps = flake8>=2.5.4, <3
|
||||||
commands = flake8 --count mitmproxy netlib pathod examples test
|
commands = flake8 --jobs 8 --count mitmproxy netlib pathod examples test
|
||||||
|
Loading…
Reference in New Issue
Block a user