Revision 44193110

b/api/middleware.py
15 15
            #Retrieve user from DB or other caching mechanism
16 16
            user = SynnefoUser.objects.filter(auth_token = request.META[self.auth_token])
17 17
            if user is None :
18
                return HttpResponseAuthenticationRequired(content='Athentication Required')
18
                return HttpResponseRedirect(content='Athentication Required')
19 19
            request.user = user
20 20
            return
21 21

  
......
30 30

  
31 31
            return HttpResponseRedirect(content= settings.SIBBOLLETH_HOST)
32 32

  
33
        return HttpResponseAuthenticationRequired(content='Athentication Required')
33
        return HttpResponseRedirect(content='Athentication Required')
34 34

  
35 35
#class HttpResponseAuthenticationRequired(HttpResponse):
36 36
#    status_code = 401
b/logic/tests.py
7 7
#
8 8

  
9 9
from synnefo.db.models import *
10

  
11 10
from synnefo.logic import credits
12 11
from synnefo.logic import users
13

  
14 12
from django.test import TestCase
13
from django.core.exceptions import ObjectDoesNotExist
14

  
15
import hashlib
15 16

  
16 17
class CostsTestCase(TestCase):
17 18
    fixtures = [ 'db_test_data' ]
......
103 104

  
104 105
class AuthTestCase(TestCase):
105 106
    fixtures = [ 'db_test_data' ]
106
    
107
    def test_register_student(self):
107

  
108
    def _register_user(self):
108 109
        users.register_student ("Jimmy Page", "jpage", "jpage@zoso.com")
109 110
        user = SynnefoUser.objects.get(name = "jpage")
110 111

  
111
        self.assertNotEquals(user, None)
112
        return user
113

  
114
    def test_register(self):
115
        """ test user registration
116
        """
117
        user = self._register_user()
118
        self.assertNotEquals(user, None)
119
        
120
        #Check hash generation
121
        md5 = hashlib.md5()
122
        md5.update(user.uniq)
123
        md5.update(user.name)
124

  
125
        self.assertEquals(user.auth_token, md5.hexdigest())
126

  
127
    def test_del_user(self):
128
        """ test user deletion
129
        """
130
        user = self._register_user()
131
        users.delete_user(user)
132
        user1 = None
133

  
134
        try:
135
            user1 = SynnefoUser.objects.get(name = "jpage")
136
        except ObjectDoesNotExist:
137
            self.assertEquals(user1, None)

Also available in: Unified diff