示例#1
0
    def test_member_names(self):
        member_names = ['one', 'two', 'three']

        enum = create_permission_enum('example', member_names)
        actual = list(enum.__members__)

        self.assertEqual(actual, member_names)
示例#2
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.seating_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


SeatingPermission = create_permission_enum("seating", ["view"])
示例#3
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.snippet_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2015 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


MountpointPermission = create_permission_enum('mountpoint', [
    'create',
    'delete',
])


SnippetPermission = create_permission_enum('snippet', [
    'list',
    'create',
    'update',
    'view_history',
])
示例#4
0
def test_key(key):
    enum = create_permission_enum(key, ['some_member'])

    assert enum.__key__ == key
示例#5
0
"""
byceps.blueprints.admin.board.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


BoardCategoryPermission = create_permission_enum('board_category', [
    'create',
    'update',
    'view',
])
示例#6
0
# -*- coding: utf-8 -*-

"""
:Copyright: 2006-2015 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from unittest import TestCase

from nose2.tools import params

from byceps.blueprints.authorization.models import Permission
from byceps.util.authorization import create_permission_enum


ExamplePermission = create_permission_enum('example', ['one', 'two', 'three'])

MultiWordPermission = create_permission_enum('multi_word', ['foo', 'bar'])


class PermissionTestCase(TestCase):

    @params(
        (ExamplePermission.one,   'example.one'   ),
        (ExamplePermission.three, 'example.three' ),
        (MultiWordPermission.foo, 'multi_word.foo'),
    )
    def test_creation_from_enum_member(self, enum_member, expected):
        actual = Permission.from_enum_member(enum_member)

        self.assertEqual(actual.id, expected)
示例#7
0
"""
byceps.blueprints.orga_team_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

OrgaTeamPermission = create_permission_enum('orga_team', [
    'create',
    'delete',
    'list',
    'administrate_memberships',
])
示例#8
0
"""
byceps.blueprints.news_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

NewsItemPermission = create_permission_enum('news_item', [
    'create',
    'update',
    'list',
])
示例#9
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.shop_order_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


ShopOrderPermission = create_permission_enum('shop_order', [
    'update',
    'list',
    'view',
])
示例#10
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.core_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


AdminPermission = create_permission_enum('admin', [
    'access',
])
示例#11
0
"""
byceps.blueprints.admin.authorization.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


RolePermission = create_permission_enum('role', [
    'assign',
    'view',
])
示例#12
0
"""
byceps.blueprints.admin.jobs.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


JobsPermission = create_permission_enum('jobs', [
    'view',
])
示例#13
0
"""
byceps.blueprints.brand_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

BrandPermission = create_permission_enum('brand', [
    'create',
    'view',
])
示例#14
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.orga_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2015 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


OrgaBirthdayPermission = create_permission_enum('orga_birthday', [
    'list',
])


OrgaDetailPermission = create_permission_enum('orga_detail', [
    'view',
])


OrgaTeamPermission = create_permission_enum('orga_team', [
    'create',
    'delete',
    'list',
    'administrate_memberships',
])
示例#15
0
"""
byceps.blueprints.board.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

BoardTopicPermission = create_permission_enum('board_topic', [
    'create',
    'update',
    'update_of_others',
    'hide',
    'lock',
    'move',
    'pin',
    'view_hidden',
])

BoardPostingPermission = create_permission_enum('board_posting', [
    'create',
    'update',
    'update_of_others',
    'hide',
    'view_hidden',
])
示例#16
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.news_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


NewsItemPermission = create_permission_enum('news_item', [
    'create',
    'update',
    'list',
])
示例#17
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.user_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2015 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


UserPermission = create_permission_enum('user', [
    'list',
])
示例#18
0
"""
byceps.blueprints.admin.user.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

UserPermission = create_permission_enum('user', [
    'administrate',
    'create',
    'set_password',
    'view',
])
示例#19
0
# -*- coding: utf-8 -*-

"""
:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from nose2.tools import params

from byceps.blueprints.authorization.registry import PermissionRegistry
from byceps.util.authorization import create_permission_enum


ItemPermission = create_permission_enum("item", ["view", "create", "update"])


@params(
    ("item.create", ItemPermission.create),  # enum member exists
    ("item.delete", None),  # enum exists, but member does not
    ("article.create", None),  # enum does not exist
)
def test_get_enum_member(permission_id, expected):
    registry = create_registry_with_registered_enum()

    assert registry.get_enum_member(permission_id) == expected


@params(
    ({"item.create", "item.create"}, {ItemPermission.create}),  # duplicates are ignored
    (
        {"item.create", "item.update"},
示例#20
0
"""
byceps.blueprints.snippet_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

MountpointPermission = create_permission_enum('mountpoint', [
    'create',
    'delete',
])

SnippetPermission = create_permission_enum('snippet', [
    'list',
    'create',
    'update',
    'view_history',
])
示例#21
0
"""
byceps.blueprints.admin.terms.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

TermsPermission = create_permission_enum('terms', [
    'create',
    'view',
])
示例#22
0
"""
byceps.blueprints.shop_article_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2018 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

ShopArticlePermission = create_permission_enum('shop_article', [
    'create',
    'update',
    'list',
    'view',
])
示例#23
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.orga_presence.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

OrgaPresencePermission = create_permission_enum('orga_presence', [
    'list',
    'update',
])
示例#24
0
"""
byceps.blueprints.admin.newsletter.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

NewsletterPermission = create_permission_enum('newsletter', [
    'export_subscribers',
    'view_subscriptions',
])
示例#25
0
"""
byceps.blueprints.admin.tourney.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

TourneyCategoryPermission = create_permission_enum('tourney_category', [
    'create',
    'update',
    'view',
])
示例#26
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.newsletter_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2015 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


NewsletterPermission = create_permission_enum('newsletter', [
    'export_subscribers',
    'view_subscriptions',
])
示例#27
0
    def test_key(self, key):
        enum = create_permission_enum(key, ['some_member'])

        self.assertEqual(enum.__key__, key)
示例#28
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.ticket_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


TicketPermission = create_permission_enum('ticket', [
    'list',
    'view',
])
示例#29
0
    def test_name_derivation(self, key, expected):
        enum = create_permission_enum(key, ['some_member'])
        actual = enum.some_member.__class__.__name__

        self.assertEqual(actual, expected)
示例#30
0
"""
byceps.blueprints.admin.site.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


SitePermission = create_permission_enum('site', [
    'create',
    'update',
    'view',
])
示例#31
0
"""
byceps.blueprints.board.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2015 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


BoardTopicPermission = create_permission_enum('board_topic', [
    'create',
    'update',
    'update_of_others',
    'hide',
    'lock',
    'move',
    'pin',
    'view_hidden',
])


BoardPostingPermission = create_permission_enum('board_posting', [
    'create',
    'update',
    'update_of_others',
    'hide',
    'view_hidden',
])
示例#32
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.party_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


PartyPermission = create_permission_enum('party', [
    'list',
    'create',
])
示例#33
0
"""
byceps.blueprints.party_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

PartyPermission = create_permission_enum('party', [
    'list',
    'create',
    'update',
])
示例#34
0
"""
byceps.blueprints.orga_presence.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

OrgaPresencePermission = create_permission_enum('orga_presence', [
    'list',
    'update',
])
示例#35
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.user_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


UserPermission = create_permission_enum("user", ["list", "view"])
示例#36
0
"""
byceps.blueprints.admin.consent.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


ConsentPermission = create_permission_enum('consent', [
    'administrate',
])
示例#37
0
"""
byceps.blueprints.admin.party.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

PartyPermission = create_permission_enum('party', [
    'create',
    'update',
    'view',
])
示例#38
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.shop_article_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


ShopArticlePermission = create_permission_enum('shop_article', [
    'create',
    'update',
    'list',
    'view',
])
示例#39
0

class PermissionRegistryTestCase(TestCase):

    def setUp(self):
        self.registry = PermissionRegistry()
        self.registry.register_enum(ItemPermission)

    def test_lookup_of_existing_enum_member(self):
        permission = create_permission('item.create')
        self.assert_get_enum_member_equals(permission, ItemPermission.create)

    def test_lookup_of_nonexistent_member_of_existing_enum(self):
        permission = create_permission('item.delete')
        self.assert_get_enum_member_equals(permission, None)

    def test_lookup_of_member_of_nonexistent_enum(self):
        permission = create_permission('article.create')
        self.assert_get_enum_member_equals(permission, None)

    def assert_get_enum_member_equals(self, permission, expected):
        actual = self.registry.get_enum_member(permission)
        self.assertEqual(actual, expected)


ItemPermission = create_permission_enum('item', ['view', 'create', 'update'])


def create_permission(id):
    return Permission(id=id)
示例#40
0
"""
byceps.blueprints.admin.core.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


AdminPermission = create_permission_enum('admin', [
    'access',
])
示例#41
0
"""
byceps.blueprints.shop_order_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2018 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


ShopOrderPermission = create_permission_enum('shop_order', [
    'update',
    'list',
    'view',
])
示例#42
0
"""
byceps.blueprints.admin_dashboard.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2018 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

AdminDashboardPermission = create_permission_enum('admin_dashboard', [
    'view_global',
    'view_brand',
    'view_party',
])
示例#43
0
"""
byceps.blueprints.user_badge_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2018 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

UserBadgePermission = create_permission_enum('user_badge', [
    'create',
])
示例#44
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.shop_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2015 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


ShopArticlePermission = create_permission_enum("shop_article", ["create", "update", "list", "view"])


ShopOrderPermission = create_permission_enum("shop_order", ["update", "list", "view"])
示例#45
0
"""
byceps.blueprints.orga_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2018 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

OrgaBirthdayPermission = create_permission_enum('orga_birthday', [
    'list',
])

OrgaDetailPermission = create_permission_enum('orga_detail', [
    'view',
])
示例#46
0
"""
byceps.blueprints.ticketing_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2018 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

TicketingPermission = create_permission_enum('ticketing', [
    'checkin',
    'view',
])
示例#47
0
"""
byceps.blueprints.admin.news.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


NewsChannelPermission = create_permission_enum('news_channel', [
    'create',
])


NewsItemPermission = create_permission_enum('news_item', [
    'create',
    'publish',
    'update',
    'view',
    'view_draft',
])
示例#48
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.tourney_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


TourneyCategoryPermission = create_permission_enum('tourney_category', [
    'list',
    'create',
    'update',
])
示例#49
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.board_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


BoardCategoryPermission = create_permission_enum('board_category', [
    'create',
    'update',
    'list',
])
示例#50
0
"""
byceps.blueprints.authorization_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

RolePermission = create_permission_enum('role', [
    'list',
    'assign',
])
示例#51
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.brand_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


BrandPermission = create_permission_enum('brand', [
    'create',
    'view',
])
示例#52
0
def test_name_derivation(key, expected):
    enum = create_permission_enum(key, ['some_member'])

    actual = enum.some_member.__class__.__name__

    assert actual == expected
示例#53
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.news_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2015 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


NewsItemPermission = create_permission_enum("news_item", ["create", "update", "list"])
示例#54
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.authorization_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2015 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


RolePermission = create_permission_enum('role', [
    'list',
])
示例#55
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.orga_team_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


OrgaTeamPermission = create_permission_enum('orga_team', [
    'create',
    'delete',
    'list',
    'administrate_memberships',
])
示例#56
0
# -*- coding: utf-8 -*-
"""
byceps.blueprints.admin_dashboard.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

AdminDashboardPermission = create_permission_enum('admin_dashboard', [
    'view_global',
    'view_brand',
    'view_party',
])
示例#57
0
"""
byceps.blueprints.seating_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum

SeatingPermission = create_permission_enum('seating', [
    'view',
])
示例#58
0
# -*- coding: utf-8 -*-

"""
byceps.blueprints.terms_admin.authorization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2015 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.util.authorization import create_permission_enum


TermsPermission = create_permission_enum('terms', [
    'list',
    'create',
])
示例#59
0
"""
:Copyright: 2006-2019 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from unittest.mock import patch

import pytest

with patch('flask.current_app'):
    from byceps.blueprints.authorization.registry import PermissionRegistry
from byceps.util.authorization import create_permission_enum

ItemPermission = create_permission_enum('item', ['view', 'create', 'update'])


@pytest.mark.parametrize(
    'permission_id, expected',
    [
        ('item.create', ItemPermission.create),  # enum member exists
        ('item.delete', None),  # enum exists, but member does not
        ('article.create', None),  # enum does not exist
    ])
def test_get_enum_member(permission_id, expected):
    registry = create_registry_with_registered_enum()

    assert registry.get_enum_member(permission_id) == expected


@pytest.mark.parametrize(
    'permission_ids, expected',