Example #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)
Example #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"])
Example #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',
])
Example #4
0
def test_key(key):
    enum = create_permission_enum(key, ['some_member'])

    assert enum.__key__ == key
Example #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',
])
Example #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)
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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"},
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #27
0
    def test_key(self, key):
        enum = create_permission_enum(key, ['some_member'])

        self.assertEqual(enum.__key__, key)
Example #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',
])
Example #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)
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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"])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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)
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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"])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #52
0
def test_name_derivation(key, expected):
    enum = create_permission_enum(key, ['some_member'])

    actual = enum.some_member.__class__.__name__

    assert actual == expected
Example #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"])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',
])
Example #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',