Esempio n. 1
0
 def test_remove_permissions(self):
     user_api.update_permissions(self.user_object.id,
                                 user=self.user_object,
                                 remove_permissions=1)
     del_user_permission = user_api.get_permissions(
         self.user_object.id,
         user=self.user_object,
     )
     self.assertEqual([], del_user_permission)
Esempio n. 2
0
 def test_get_permissions(self):
     user_permissions = user_api.get_permissions(
         self.user_object,
         self.user_object.id
     )
     self.assertIsNotNone(user_permissions)
     result = []
     for user_permission in user_permissions:
         result.append(user_permission['name'])
     self.assertIn('list_permissions', result)
Esempio n. 3
0
 def test_get_permissions(self):
     user_permissions = user_api.get_permissions(
         self.user_object.id,
         user=self.user_object,
     )
     self.assertIsNotNone(user_permissions)
     result = []
     for user_permission in user_permissions:
         result.append(user_permission['name'])
     self.assertIn('list_permissions', result)
Esempio n. 4
0
 def test_remove_permissions(self):
     user_api.update_permissions(
         self.user_object,
         self.user_object.id,
         remove_permissions=1
     )
     del_user_permission = user_api.get_permissions(
         self.user_object,
         self.user_object.id
     )
     self.assertEqual([], del_user_permission)
Esempio n. 5
0
 def test_del_permission(self):
     user_api.del_permission(
         self.user_object,
         self.user_object.id,
         1
     )
     del_user = user_api.get_permissions(
         self.user_object,
         self.user_object.id
     )
     self.assertEqual([], del_user)
Esempio n. 6
0
 def test_del_permission(self):
     user_api.del_permission(
         self.user_object.id,
         1,
         user=self.user_object,
     )
     del_user = user_api.get_permissions(
         self.user_object.id,
         user=self.user_object,
     )
     self.assertEqual([], del_user)
Esempio n. 7
0
 def test_add_permissions(self):
     user_api.update_permissions(self.user_object.id,
                                 user=self.user_object,
                                 add_permissions=2)
     permissions = user_api.get_permissions(
         self.user_object.id,
         user=self.user_object,
     )
     result = None
     for permission in permissions:
         if permission['id'] == 2:
             result = permission['name']
     self.assertEqual(result, 'list_switches')
Esempio n. 8
0
 def test_add_permissions(self):
     user_api.update_permissions(
         self.user_object,
         self.user_object.id,
         add_permissions=2
     )
     permissions = user_api.get_permissions(
         self.user_object,
         self.user_object.id
     )
     result = None
     for permission in permissions:
         if permission['id'] == 2:
             result = permission['name']
     self.assertEqual(result, 'list_switches')
Esempio n. 9
0
 def test_add_permission_session(self):
     with database.session() as session:
         user_api.add_permission(self.user_object.id,
                                 user=self.user_object,
                                 permission_id=2,
                                 session=session)
     permissions = user_api.get_permissions(
         self.user_object.id,
         user=self.user_object,
     )
     result = None
     for permission in permissions:
         if permission['id'] == 2:
             result = permission['name']
     self.assertEqual(result, 'list_switches')
Esempio n. 10
0
 def test_add_permission_position(self):
     user_api.add_permission(
         self.user_object.id,
         True,
         2,
         user=self.user_object,
     )
     permissions = user_api.get_permissions(
         self.user_object.id,
         user=self.user_object,
     )
     result = None
     for permission in permissions:
         if permission['id'] == 2:
             result = permission['name']
     self.assertEqual(result, 'list_switches')
Esempio n. 11
0
 def test_add_permission_session(self):
     with database.session() as session:
         user_api.add_permission(
             self.user_object.id,
             user=self.user_object,
             permission_id=2,
             session=session
         )
     permissions = user_api.get_permissions(
         self.user_object.id,
         user=self.user_object,
     )
     result = None
     for permission in permissions:
         if permission['id'] == 2:
             result = permission['name']
     self.assertEqual(result, 'list_switches')
Esempio n. 12
0
def get_user_permissions(user_id):
    """Get user permissions."""
    data = _get_request_args()
    return utils.make_json_response(
        200, user_api.get_permissions(current_user, user_id, **data)
    )