Example #1
0
def test_base_controller_authorize_no_role():
    bc = BaseController()
    model = 'something'
    bc.guard = Guard()
    ctx = Context()
    ctx.identity = Identity([])
    bc.authorize(ctx, 'read', model)
Example #2
0
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)
Example #3
0
def test_base_controller_authorize_no_ctx():
    bc = BaseController()
    model = 'something'
    bc.guard = Guard()
    ctx = None
    bc.authorize(ctx, 'read', model)
Example #4
0
def test_base_controller_authorize():
    bc = BaseController()
    model = 'something'
    ctx = Context()
    assert_equal(bc.authorize(ctx, 'read', model), model)
Example #5
0
def test_base_controller_model_name():
    bc = BaseController()
    assert_equal(bc.model_name, 'BaseController')

    bc.model = SomeModel
    assert_equal(bc.model_name, 'SomeModel')