Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use request.get_full_path() to work with queryargs.

  • Loading branch information...
commit 0bfc1c6c3167025bdc9346e0f7bca32aa518b726 1 parent e107eb9
@Almad authored
View
5 djangohttpdigest/decorators.py
@@ -10,7 +10,7 @@ def protect_digest(realm, username, password):
def _innerDecorator(function):
def _wrapper(request, *args, **kwargs):
- digestor = Digestor(method=request.method, path=request.path, realm=realm)
+ digestor = Digestor(method=request.method, path=request.get_full_path(), realm=realm)
if request.META.has_key('HTTP_AUTHORIZATION'):
try:
@@ -35,7 +35,8 @@ def protect_digest_model(model, realm, realm_field='realm', username_field='user
def _innerDecorator(function):
def _wrapper(request, *args, **kwargs):
- digestor = Digestor(method=request.method, path=request.path, realm=realm)
+ digestor = Digestor(method=request.method, path=request.get_full_path(), realm=realm)
+
if request.META.has_key('HTTP_AUTHORIZATION'):
try:
parsed_header = digestor.parse_authorization_header(request.META['HTTP_AUTHORIZATION'])
View
2  testproject/settings.py
@@ -49,4 +49,4 @@
)
TEST_DATABASE_CHARSET="utf8"
-TEST_RUNNER='djangosanetesting.testrunner.DstNoseTestSuiteRunner'
+#TEST_RUNNER='djangosanetesting.testrunner.DstNoseTestSuiteRunner'
View
25 testproject/tests/test_simple_digest.py
@@ -1,6 +1,6 @@
import urllib2
import logging
-from md5 import md5
+from hashlib import md5
from djangohttpdigest.client import HttpDigestClient
from django.db import transaction
@@ -100,3 +100,26 @@ def test_autentization_compatible_model_with_cleartext_field_without_realm(self)
self._check_authentication_compatibility(path='/testapi/modelcleartextprotectedwithdefaultrealm/')
+ def test_authentication_works_with_query_args(self):
+ """ Tests URIs are available even when requested with query arguments. """
+ ClearTextModelWithDefaultRealm.objects.create(username='username', password='password')
+ transaction.commit()
+
+ auth_handler = urllib2.HTTPDigestAuthHandler()
+ auth_handler.add_password('simple', self.url, 'username', 'password')
+ opener = urllib2.build_opener(auth_handler)
+
+ request = urllib2.Request(self.url+'/testapi/simpleprotected/?query=arg')
+
+ try:
+ response = opener.open(request)
+ except urllib2.HTTPError, err:
+ if err.fp:
+ error = ": %s" % err.fp.read()
+ else:
+ error = ''
+ logging.error("Error occured while opening HTTP %s" % error)
+ raise
+ self.assertEquals(200, response.code)
+ response.close()
+
Please sign in to comment.
Something went wrong with that request. Please try again.