diff --git a/.travis.yml b/.travis.yml index 7796bb8a..128885c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,7 @@ language: python python: - "2.6" - "2.7" + - "3.3" + - "3.4" install: "pip install -r requirements.txt" script: py.test diff --git a/oauth2/__init__.py b/oauth2/__init__.py index 36f5726c..6a5e6877 100644 --- a/oauth2/__init__.py +++ b/oauth2/__init__.py @@ -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 diff --git a/tests/test_oauth.py b/tests/test_oauth.py index bae3e514..2adcac04 100644 --- a/tests/test_oauth.py +++ b/tests/test_oauth.py @@ -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') @@ -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: