class Assets(Resource): """ Manipulations with Assets. """ @api.login_required(oauth_scopes=['assets:read']) @api.permission_required(permissions.AdminRolePermission()) @api.response(schemas.BaseAssetSchema(many=True)) @api.parameters(PaginationParameters()) def get(self, args): """ List of Assets. Returns a list of Asset starting from ``offset`` limited by ``limit`` parameter. """ return Asset.query.offset(args['offset']).limit(args['limit']) @api.login_required(oauth_scopes=['assets:write']) @api.permission_required(permissions.AdminRolePermission()) @api.response(schemas.DetailedAssetSchema()) @api.response(code=HTTPStatus.CONFLICT) def post(self): """ Create a new instance of Asset. """ return process_file_upload()
def test_AdminRolePermission_authenticated_user(authenticated_user_instance): authenticated_user_instance.is_admin = True with permissions.AdminRolePermission(): pass authenticated_user_instance.is_admin = False with pytest.raises(HTTPException): with permissions.AdminRolePermission(): pass
def test_AdminRolePermission_authenticated_user_with_password_is_admin( authenticated_user_instance): authenticated_user_instance.password = "******" authenticated_user_instance.is_admin = True with permissions.AdminRolePermission(password_required=True, password="******"): pass with pytest.raises(HTTPException): with permissions.AdminRolePermission(password_required=True, password="******"): pass
def test_AdminRolePermission_authenticated_user_with_password_not_admin( authenticated_user_instance, ): authenticated_user_instance.password = '******' authenticated_user_instance.is_admin = False with pytest.raises(HTTPException): with permissions.AdminRolePermission( password_required=True, password='******' ): pass with pytest.raises(HTTPException): with permissions.AdminRolePermission( password_required=True, password='******' ): pass
def test_AdminRolePermission_anonymous_user_with_password(anonymous_user_instance): # pylint: disable=unused-argument with pytest.raises(HTTPException): with permissions.AdminRolePermission( password_required=True, password='******' ): pass
class Develop(Resource): @api.login_required(oauth_scopes=['users:read']) @api.permission_required(permissions.AdminRolePermission()) def get(self): """ from app.modules.auth.models import Codes """ ut.embed() return True
class AssetByID(Resource): """ Manipulations with a specific Asset. """ @api.permission_required(permissions.AdminRolePermission()) @api.response(schemas.DetailedAssetSchema()) def get(self, asset): """ Get Asset details by ID. """ return asset
class Assets(Resource): """ Manipulations with Assets. """ @api.login_required(oauth_scopes=['assets:read']) @api.permission_required(permissions.AdminRolePermission()) @api.response(schemas.BaseAssetSchema(many=True)) @api.parameters(PaginationParameters()) def get(self, args): """ List of Assets. Returns a list of Asset starting from ``offset`` limited by ``limit`` parameter. """ return (Asset.query.order_by(Asset.guid).offset(args['offset']).limit( args['limit']))
def test_AdminRolePermission_anonymous_user(anonymous_user_instance): # pylint: disable=unused-argument with pytest.raises(HTTPException): with permissions.AdminRolePermission(): pass