New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add RESTful API for mitmweb option #2395

Merged
merged 8 commits into from Jun 24, 2017

Conversation

Projects
None yet
3 participants
@MatthewShao
Contributor

MatthewShao commented Jun 13, 2017

  • Implement GET /options
  • Implement POST /options
    The return json looks like this:
[
    {
        "default": false, 
        "help": "Add all certificates of the upstream server to the certificate chain that will be served to the proxy client, as extras.", 
        "name": "add_upstream_certs_to_client_chain", 
        "type": "bool", 
        "value": false
    }, 
    {
        "default": false, 
        "help": "Strip out request headers that might cause the server to return 304-not-modified.", 
        "name": "anticache", 
        "type": "bool", 
        "value": false
    }, 
...]

The tests passed on my local repo, but kept falling on Travis... Is that because of some compatibility problem?

@mhils

Good stuff! All comments are really complaints on a high level. :)

I haven't seen travis fail here, but I guess this is due to @Kriechi's draconian fantastic coverage checks. We should add a test for the API call in https://github.com/mitmproxy/mitmproxy/blob/master/test/mitmproxy/tools/web/test_app.py. :)

Show outdated Hide outdated mitmproxy/optmanager.py
Show outdated Hide outdated mitmproxy/optmanager.py
Show outdated Hide outdated mitmproxy/optmanager.py
@mhils

Looks good so far! A few comments below, feel free to address those after your essays. :-)

def test_option_update(self):
assert self.put_json("/options", {"anticache": True}).code == 200
assert self.put_json("/options", {"wtf": True}).code == 400

This comment has been minimized.

@mhils

mhils Jun 23, 2017

Member

We should also test type confusion here (e.g. {"anticache": "foo"})

@mhils

mhils Jun 23, 2017

Member

We should also test type confusion here (e.g. {"anticache": "foo"})

@@ -98,3 +98,15 @@ def check_option_type(name: str, value: typing.Any, typeinfo: typing.Any) -> Non
return
elif not isinstance(value, typeinfo):
raise e
def typespec_to_str(typespec: typing.Any) -> str:

This comment has been minimized.

@mhils

mhils Jun 23, 2017

Member

We should also use this in dump_defaults

@mhils

mhils Jun 23, 2017

Member

We should also use this in dump_defaults

Show outdated Hide outdated mitmproxy/utils/typecheck.py
@mhils

mhils approved these changes Jun 24, 2017

👍 🍰

@mhils mhils merged commit bde6474 into mitmproxy:master Jun 24, 2017

4 checks passed

codecov/patch 100% of diff hit (target 87.29%)
Details
codecov/project 87.31% (+0.01%) compared to ba38a12
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment