Beispiel #1
0
def test_require_group_passed(perm):
    from flask_perm.services import UserGroupService, UserGroupMemberService
    user_group = UserGroupService.create(
        'Test require_group passed',
        'test.require_group_passed',
    )
    member = UserGroupMemberService.create(user_id=1, user_group_id=user_group.id)
    assert perm.require_group('test.require_group_passed')(lambda: True)()
    assert perm.require_group_in_template('test.require_group_passed')
    assert perm.require_group('*')(lambda: True)()
Beispiel #2
0
def test_require_group_passed(perm):
    from flask_perm.services import UserGroupService, UserGroupMemberService
    user_group = UserGroupService.create(
        'Test require_group passed',
        'test.require_group_passed',
    )
    member = UserGroupMemberService.create(user_id=1,
                                           user_group_id=user_group.id)
    assert perm.require_group('test.require_group_passed')(lambda: True)()
    assert perm.require_group_in_template('test.require_group_passed')
    assert perm.require_group('*')(lambda: True)()
Beispiel #3
0
def test_require_group_failed(perm):
    from flask_perm.services import UserGroupService, UserGroupMemberService
    user_group = UserGroupService.create(
        'Test require_group failed',
        'test.require_group_failed',
    )
    member = UserGroupMemberService.create(user_id=2, user_group_id=user_group.id)
    with raises(perm.Denied):
        assert perm.require_group('test.require_group_passed')(lambda: True)()
    assert not perm.require_group_in_template('test.require_group_passed')
    with raises(perm.Denied):
        assert perm.require_group('*')(lambda: True)()
Beispiel #4
0
def test_require_group_failed(perm):
    from flask_perm.services import UserGroupService, UserGroupMemberService
    user_group = UserGroupService.create(
        'Test require_group failed',
        'test.require_group_failed',
    )
    member = UserGroupMemberService.create(user_id=2,
                                           user_group_id=user_group.id)
    with raises(perm.Denied):
        assert perm.require_group('test.require_group_passed')(lambda: True)()
    assert not perm.require_group_in_template('test.require_group_passed')
    with raises(perm.Denied):
        assert perm.require_group('*')(lambda: True)()