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

Lowercase scheme and authority per specification. #183

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion oauth2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ def url(self, value):
raise ValueError("Unsupported URL %s (%s)." % (value, scheme))

# Normalized URL excludes params, query, and fragment.
self.normalized_url = urlunsplit((scheme, netloc, path, None, None))
self.normalized_url = urlunsplit((scheme.lower(),
netloc.lower(), path, None, None))
else:
self.normalized_url = None
self.__dict__['url'] = None
Expand Down
8 changes: 8 additions & 0 deletions tests/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,14 @@ def test_url(self):
self.assertEqual(req.normalized_url, exp2)
self.assertEqual(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