コード例 #1
0
def test_permission_difference_denial():
    p1 = Denial(('a', 'b'), ('a', 'c'))
    p2 = Denial(('a', 'c'), ('d', 'e'))
    p3 = p1.difference(p2)
    assert p3.excludes == set([('a', 'b')])
    p4 = p2.difference(p1)
    assert p4.excludes == set([('d', 'e')])
コード例 #2
0
ファイル: post.py プロジェクト: yxm0513/7topdig
        def vote(self):
            needs = [
                UserNeed(User.query.get(user_id).username)
                for user_id in self.votes
            ]
            needs.append(UserNeed(self.author.username))

            return auth & Denial(*needs)
コード例 #3
0
def test_permission_difference_denial():
    p1 = Denial(('a', 'b'), ('a', 'c'))
    p2 = Denial(('a', 'c'), ('d', 'e'))
    p3 = p1.difference(p2)
    assert p3.excludes == set([('a', 'b')])
    p4 = p2.difference(p1)
    assert p4.excludes == set([('d', 'e')])
コード例 #4
0
def test_permission_union_denial():
    p1 = Permission(('a', 'b'))
    p2 = Denial(('a', 'c'))
    p3 = p1.union(p2)
    assert p1.issubset(p3)
    assert p2.issubset(p3)
コード例 #5
0
ファイル: comments.py プロジェクト: xenron/sandbox-dev-python
        def vote(self):

            needs = [UserNeed(user_id) for user_id in self.votes]
            needs.append(UserNeed(self.author_id))

            return auth & Denial(*needs)
コード例 #6
0
def test_permission_union_denial():
    p1 = Permission(('a', 'b'))
    p2 = Denial(('a', 'c'))
    p3 = p1.union(p2)
    assert p1.issubset(p3)
    assert p2.issubset(p3)
コード例 #7
0
    if identity.name == 'ali':
        identity.provides.add(RoleNeed('admin'))


class ReraiseException(Exception):
    """For checking reraising"""


admin_permission = Permission(RoleNeed('admin'))
anon_permission = Permission()

admin_or_editor = Permission(RoleNeed('admin'), RoleNeed('editor'))

editor_permission = Permission(RoleNeed('editor'))

admin_denied = Denial(RoleNeed('admin'))


def mkapp():
    app = Flask(__name__)
    app.secret_key = 'notverysecret'
    app.debug = True

    p = Principal(app)

    identity_loaded.connect(_on_principal_init)

    @app.route('/')
    def index():
        with admin_permission.require():
            pass