Commits

Lukas Linhart committed 48325f7

Fixed Django 1.1 changes + commit in httptestcase

Comments (0)

Files changed (2)

djangohttpdigest/decorators.py

 from django.http import HttpResponseBadRequest
 
-from http import HttpResponseNotAuthorized
-from digest import Digestor, parse_authorization_header
-from authentication import SimpleHardcodedAuthenticator, ModelAuthenticator
+from djangohttpdigest.http import HttpResponseNotAuthorized
+from djangohttpdigest.digest import Digestor, parse_authorization_header
+from djangohttpdigest.authentication import SimpleHardcodedAuthenticator, ModelAuthenticator
 
 __all__ = ("protect_digest", "protect_digest_model")
 
             digestor = Digestor(method=request.method, path=request.path, realm=realm)
             
             if request.META.has_key('HTTP_AUTHORIZATION'):
-                # successfull auth
-                if request.META['AUTH_TYPE'].lower() != 'digest':
-                    raise NotImplementedError("Only digest supported")
-                
                 try:
                     parsed_header = digestor.parse_authorization_header(request.META['HTTP_AUTHORIZATION'])
                 except ValueError, err:
             digestor = Digestor(method=request.method, path=request.path, realm=realm)
             
             if request.META.has_key('HTTP_AUTHORIZATION'):
-                # successfull auth
-                if request.META['AUTH_TYPE'].lower() != 'digest':
-                    raise NotImplementedError("Only digest supported")
-                
                 try:
                     parsed_header = digestor.parse_authorization_header(request.META['HTTP_AUTHORIZATION'])
                 except ValueError, err:

testproject/tests/test_simple_digest.py

 from md5 import md5
 from djangohttpdigest.client import HttpDigestClient
 
+from django.db import transaction
+
 from djangosanetesting import HttpTestCase
 
 class TestSimpleDigest(HttpTestCase):
     def test_autentization_compatible_model(self):
         # add something to test agains
         from testapi.models import ModelWithRealmSet
-        
-        ModelWithRealmSet.objects.create(realm='simple', username='username', secret=md5("%s:%s:%s" % ("username", "simple", "password")).hexdigest()) 
+        secret = md5("%s:%s:%s" % ("username", "simple", "password")).hexdigest()
+        ModelWithRealmSet.objects.create(realm='simple', username='username', secret=secret)
+
+        transaction.commit()
         
         self._check_authentication_compatibility(path='/testapi/modelprotected/')