Esempio n. 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)
Esempio n. 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)
Esempio n. 3
0
def test_base_controller_authorize_no_ctx():
    bc = BaseController()
    model = 'something'
    bc.guard = Guard()
    ctx = None
    bc.authorize(ctx, 'read', model)
Esempio n. 4
0
def test_base_controller_authorize():
    bc = BaseController()
    model = 'something'
    ctx = Context()
    assert_equal(bc.authorize(ctx, 'read', model), model)