mirror of
https://github.com/pinry/pinry.git
synced 2026-02-04 21:49:26 +01:00
Fix: Fix permission check for tastypie / update to 0.14.1
This commit is contained in:
@@ -33,11 +33,3 @@ class CombinedAuthBackend(object):
|
||||
return User.objects.get(pk=user_id)
|
||||
except User.DoesNotExist:
|
||||
return None
|
||||
|
||||
def has_perm(self, user, perm, obj=None):
|
||||
"""
|
||||
A very simplistic authorization mechanism for now. Basically a pin owner can do anything with the pin.
|
||||
"""
|
||||
if obj and isinstance(obj, Pin):
|
||||
return obj.submitter == user
|
||||
return False
|
||||
|
||||
@@ -34,21 +34,6 @@ class CombinedAuthBackendTest(TestCase):
|
||||
def test_authenticate_unknown_user(self):
|
||||
self.assertIsNone(self.backend.authenticate(username='wrong-username', password='wrong-password'))
|
||||
|
||||
@mock.patch('requests.get', mock_requests_get)
|
||||
def test_has_perm_on_pin(self):
|
||||
image = Image.objects.create_for_url('http://testserver/mocked/screenshot.png')
|
||||
user = User.objects.get(username=self.username)
|
||||
pin = Pin.objects.create(submitter=user, image=image)
|
||||
self.assertTrue(self.backend.has_perm(user, 'add_pin', pin))
|
||||
|
||||
@mock.patch('requests.get', mock_requests_get)
|
||||
def test_has_perm_on_pin_unauthorized(self):
|
||||
image = Image.objects.create_for_url('http://testserver/mocked/screenshot.png')
|
||||
user = User.objects.get(username=self.username)
|
||||
other_user = User.objects.create_user('test', 'test@example.com', 'test')
|
||||
pin = Pin.objects.create(submitter=user, image=image)
|
||||
self.assertFalse(self.backend.has_perm(other_user, 'add_pin', pin))
|
||||
|
||||
|
||||
class CreateUserTest(TestCase):
|
||||
def test_create_post(self):
|
||||
|
||||
Reference in New Issue
Block a user