0001-dj22-use-user.is_authenticated-as-a-boolean-or-calla.patch
hobo/rest_authentication.py | ||
---|---|---|
8 | 8 |
from django.conf import settings |
9 | 9 |
from django.contrib.auth.models import AnonymousUser |
10 | 10 |
from django.db.models.fields import FieldDoesNotExist |
11 |
from django.utils.deprecation import CallableTrue |
|
11 | 12 |
from django.utils.module_loading import import_string |
12 | 13 | |
13 | 14 |
try: |
... | ... | |
18 | 19 | |
19 | 20 |
class AnonymousAuthenticServiceUser(AnonymousUser): |
20 | 21 |
'''This virtual user hold permissions for other publik services''' |
21 |
is_authenticated = True |
|
22 |
is_anonymous = True |
|
22 | ||
23 |
@property |
|
24 |
def is_anonymous(self): |
|
25 |
return CallableTrue |
|
26 | ||
27 |
@property |
|
28 |
def is_authenticated(self): |
|
29 |
return CallableTrue |
|
23 | 30 | |
24 | 31 |
def has_perm(self, perm_or_perms, obj=None): |
25 | 32 |
return True |
... | ... | |
41 | 48 |
class AnonymousAdminServiceUser(AnonymousUser): |
42 | 49 |
'''This virtual user hold permissions for other publik services''' |
43 | 50 |
is_staff = True |
44 |
is_authenticated = True |
|
45 |
is_anonymous = True |
|
51 | ||
52 |
@property |
|
53 |
def is_anonymous(self): |
|
54 |
return CallableTrue |
|
55 | ||
56 |
@property |
|
57 |
def is_authenticated(self): |
|
58 |
return CallableTrue |
|
46 | 59 | |
47 | 60 |
def __unicode__(self): |
48 | 61 |
return 'Publik Service Admin' |
tests_authentic/test_rest_authentication.py | ||
---|---|---|
47 | 47 |
assert len(result) == 2 |
48 | 48 |
assert result[0].__class__ is rest_authentication.AnonymousAdminServiceUser |
49 | 49 |
assert result[0].is_authenticated |
50 |
assert result[0].is_authenticated() |
|
51 |
assert result[0].is_anonymous |
|
52 |
assert result[0].is_anonymous() |
|
50 | 53 |
assert result[0].is_staff |
51 | 54 |
assert result[1] is None |
52 | 55 | |
53 |
- |