Ejemplo n.º 1
0
 def test_put_lockaccess_not_admin(self):
     url = "/users/2/lockaccesses/2/"
     payload = dumps({'id': 2, 'is_admin': True, 'lock_id': 1, 'user_id': 2})
     response = self.client.put(url, payload, content_type="application/json", HTTP_AUTHORIZATION='Bearer ' + get_valid_token_user2())
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Ejemplo n.º 2
0
 def test_delete_lockaccess_not_admin(self):
     url = "/users/2/lockaccesses/2/"
     response = self.client.delete(url, HTTP_AUTHORIZATION='Bearer ' + get_valid_token_user2())
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Ejemplo n.º 3
0
 def test_post_lockaccesses_admin(self):
     url = "/users/2/lockaccesses/"
     payload = dumps({'is_admin': True, 'lock_id': 2, 'user_id': 1})
     response = self.client.post(url, data=payload, content_type="application/json", HTTP_AUTHORIZATION='Bearer ' + get_valid_token_user2())
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Ejemplo n.º 4
0
 def test_delete_locklogs_authenticated_isnoadmin(self):
     url = "/users/2/locks/1/logs/"
     response = self.client.delete(url, HTTP_AUTHORIZATION='Bearer ' + get_valid_token_user2())
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Ejemplo n.º 5
0
 def test_get_own_lockaccess_not_admin(self):
     url = "/users/2/lockaccesses/2/"
     response = self.client.get(url, HTTP_AUTHORIZATION='Bearer ' + get_valid_token_user2())
     self.assertEqual(response.status_code, status.HTTP_200_OK)
Ejemplo n.º 6
0
 def test_get_log_not_admin(self):
     url = "/users/2/logs/2/"
     response = self.client.get(url, HTTP_AUTHORIZATION='Bearer ' + get_valid_token_user2())
     self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
Ejemplo n.º 7
0
 def test_patch_lock_name_authenticated_no_admin(self):
     url = "/users/2/locks/1/"
     payload = dumps({"name": "new name"})
     response = self.client.patch(url, payload, content_type="application/json", HTTP_AUTHORIZATION='Bearer ' + get_valid_token_user2())
     lock = Esloq.objects.get(id=1)
     self.assertEqual(lock.name, "Lock One")
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)