Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pypac/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
except ImportError:
from urlparse import urlparse # noqa
try:
from urllib.parse import quote_plus
from urllib.parse import quote
except ImportError:
from urllib import quote_plus # noqa
from urllib import quote # noqa

from pypac.parser import parse_pac_value

Expand Down Expand Up @@ -128,7 +128,7 @@ def add_proxy_auth(possible_proxy_url, proxy_auth):
return possible_proxy_url
parsed = urlparse(possible_proxy_url)
return "{0}://{1}:{2}@{3}".format(
parsed.scheme, quote_plus(proxy_auth.username), quote_plus(proxy_auth.password), parsed.netloc
parsed.scheme, quote(proxy_auth.username, safe=""), quote(proxy_auth.password, safe=""), parsed.netloc
)


Expand Down
7 changes: 7 additions & 0 deletions tests/test_resolver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from requests.auth import HTTPProxyAuth
from requests.utils import get_auth_from_url

from pypac.parser import PACFile, proxy_url
from pypac.resolver import ProxyResolver, add_proxy_auth, ProxyConfigExhaustedError
Expand Down Expand Up @@ -61,6 +62,12 @@ def test_resolver_add_proxy_auth():
assert res.get_proxy(arbitrary_url) == "http://user:pwd@foo:8080"


def test_requests_proxy_auth():
pypac_auth = HTTPProxyAuth("user", "Pass phr@s3+/")
requests_auth = get_auth_from_url(add_proxy_auth(arbitrary_url, pypac_auth))
assert (pypac_auth.username, pypac_auth.password) == requests_auth


def test_get_proxy_for_requests():
res = _get_resolver("DIRECT")
assert res.get_proxy_for_requests(arbitrary_url) == {"http": None, "https": None}
Expand Down
Loading