Skip to content

Lowercase scheme and authority per specification. #175

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

Closed
wants to merge 4 commits into from
Closed
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
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ language: python
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
install: "pip install -r requirements.txt"
script: py.test
3 changes: 2 additions & 1 deletion oauth2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ def url(self, value):
raise ValueError("Unsupported URL %s (%s)." % (value, scheme))

# Normalized URL excludes params, query, and fragment.
self.normalized_url = urlparse.urlunsplit((scheme, netloc, path, None, None))
self.normalized_url = urlparse.urlunsplit((scheme.lower(),
netloc.lower(), path, None, None))
else:
self.normalized_url = None
self.__dict__['url'] = None
Expand Down
10 changes: 9 additions & 1 deletion tests/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def _compare_tokens(self, new):
# TODO: What about copying the verifier to the new token?
# self.assertEqual(self.token.verifier, new.verifier)

def test_to_string(self):
def test_to_string_magic_method(self):
tok = oauth.Token('tooken', 'seecret')
self.assertEqual(str(tok), 'oauth_token_secret=seecret&oauth_token=tooken')

Expand Down Expand Up @@ -303,6 +303,14 @@ def test_url(self):
self.assertEquals(req.normalized_url, exp2)
self.assertEquals(req.url, url2)

def test_url_lowercases_scheme_and_authority(self):
"""Lowercase scheme and authority in URL normalization."""
# http://oauth.net/core/1.0a/#rfc.section.9.1.2
# https://github.com/joestump/python-oauth2/issues/29
url = 'HTTP://Example.com/resource'
req = oauth.Request("GET", url)
self.assertEquals(req.normalized_url, "http://example.com/resource")

def test_bad_url(self):
request = oauth.Request()
try:
Expand Down