Skip to content
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

Eve broken with werzeug >= 0.15.3 #1267

Closed
sunbit opened this issue May 15, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@sunbit
Copy link
Contributor

commented May 15, 2019

I actually realized of this when tests failed from a PR i was preparing, and then tests on travis also failed. After some debugging i tracked down the error to werkzeug, and to this particular change referenced in this issue

pallets/werkzeug#1516
pallets/werkzeug@4ee2464

If i understant correctly, they are fixing something that was not right, but it breaks the expected value format of exceptions www_authenticate parameter here:

https://github.com/pyeve/eve/blob/master/eve/endpoints.py#L173:L174

were eve was expecting a (None,) when now it's simply None.

I'm not sure if this should be considered something wrong on werkzeug's side for changing that behavoir and file a bug there, or fix such assumption in eve.

What do you think?


Expected Behavior

Test pass in any environment

Actual Behavior

Auth tests fail when using werkzeug >=0.15.3

======================================================== test session starts ========================================================
platform darwin -- Python 2.7.16, pytest-4.5.0, py-1.8.0, pluggy-0.11.0
cachedir: .tox/py27/.pytest_cache
rootdir: /private/tmp/eve, inifile: pytest.ini
collected 796 items                                                                                                                 

eve/tests/auth.py .....F....F

============================================================= FAILURES ==============================================================
____________________________________________ TestBasicAuth.test_authorized_media_access _____________________________________________

self = <eve.tests.auth.TestBasicAuth testMethod=test_authorized_media_access>

    def test_authorized_media_access(self):
        self.app.config["RETURN_MEDIA_AS_BASE64_STRING"] = False
        self.app.config["RETURN_MEDIA_AS_URL"] = True
        self.app.config["BANDWIDTH_SAVER"] = False
        self.app._init_media_endpoint()
    
        clean = b"my new file contents"
        test_field, test_value = "ref", "9234567890123456789054321"
        data = {"media": (BytesIO(clean), "test.txt"), test_field: test_value}
        r, s = self.parse_response(
            self.test_client.post(
                self.known_resource_url, data=data, headers=self.valid_media_auth
            )
        )
        self.assert201(s)
    
        file_url = r["media"]
        r = self.test_client.get(file_url, headers=self.invalid_auth)
>       self.assert401(r.status_code)

eve/tests/auth.py:155: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
eve/tests/__init__.py:339: in assert401
    self.assertEqual(status, 401)
E   AssertionError: 500 != 401
--------------------------------------------------------- Captured log call ---------------------------------------------------------
ERROR    flask.app:app.py:1761 Exception on /media/5cdc2983d9d4670e2cbf4687 [GET]
Traceback (most recent call last):
  File "/private/tmp/eve/.tox/py27/lib/python2.7/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/private/tmp/eve/.tox/py27/lib/python2.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/private/tmp/eve/.tox/py27/lib/python2.7/site-packages/flask/app.py", line 1713, in handle_user_exception
    return self.handle_http_exception(e)
  File "/private/tmp/eve/.tox/py27/lib/python2.7/site-packages/flask/app.py", line 1644, in handle_http_exception
    return handler(e)
  File "/private/tmp/eve/eve/endpoints.py", line 182, in error_endpoint
    return send_response(None, (response, None, None, error.code, headers))
  File "/private/tmp/eve/eve/render.py", line 52, in decorated
    r = f(*args, **kwargs)
  File "/private/tmp/eve/eve/render.py", line 92, in send_response
    return _prepare_response(resource, *response if response else [None])
  File "/private/tmp/eve/eve/render.py", line 164, in _prepare_response
    for header, value in headers:
TypeError: 'NoneType' object is not iter

Environment

  • Python version: any python version
  • Eve version: master

wangsha added a commit to wangsha/eve that referenced this issue May 16, 2019

Update auth.py
issue fixes: pyeve#1267

@wangsha wangsha referenced this issue May 16, 2019

Merged

Update auth.py #1

@nicolaiarocci nicolaiarocci added this to the 1.3.2 milestone May 16, 2019

@nicolaiarocci

This comment has been minimized.

Copy link
Member

commented May 16, 2019

They sure have been playing around a lot with that Unauthorized thing. 0.15.1 broke it, and now 0.15.3 does it again 😄 I have pinned Werkzeug to 0.15.3 for the time being. We'll see if their API stabilizes over time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.