Skip to content

Commit

Permalink
Merge pull request #470 from mattbennett/rabbit-mgmt-auth-headers
Browse files Browse the repository at this point in the history
Rabbit mgmt auth headers
  • Loading branch information
mattbennett committed Oct 6, 2017
2 parents 770576d + b16c6ba commit 101e71e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 9 additions & 0 deletions nameko/testing/rabbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import six
from requests import ConnectionError, HTTPError, Session
from requests.auth import HTTPBasicAuth
from requests.utils import get_auth_from_url, urldefragauth
from six.moves.urllib.parse import quote # pylint: disable=E0401


Expand All @@ -16,8 +18,15 @@ class Client(object):
"""Pyrabbit replacement using requests instead of httplib2 """

def __init__(self, uri):

# move basic auth creds into headers to avoid
# https://github.com/requests/requests/issues/4275
username, password = get_auth_from_url(uri)
uri = urldefragauth(uri)

self._base_url = '{}/api'.format(uri)
self._session = Session()
self._session.auth = HTTPBasicAuth(username, password)
self._session.headers['content-type'] = 'application/json'
self._verify_api_connection()

Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ deps =
oldest: kombu==3.0.30
oldest: mock==1.2.0
oldest: path.py==6.2
py27-oldest: requests==1.2.0
py{34,35,36}-oldest: requests==2.0.0
oldest: requests==2.4.3
oldest: six==1.10.0
oldest: werkzeug==0.9
oldest: wrapt==1.0.0
Expand Down

0 comments on commit 101e71e

Please sign in to comment.