def test_base_controller_authorize_no_role(): bc = BaseController() model = 'something' bc.guard = Guard() ctx = Context() ctx.identity = Identity([]) bc.authorize(ctx, 'read', model)
def test_base_controller_authorize_successful(): bc = BaseController() model = SomeModel() bc.guard = Guard() bc.model = SomeModel ctx = Context() role = Role() role.grant('read', SomeModel) ctx.identity = Identity([role]) bc.authorize(ctx, 'read', model)
def test_base_controller_authorize_no_ctx(): bc = BaseController() model = 'something' bc.guard = Guard() ctx = None bc.authorize(ctx, 'read', model)