コード例 #1
0
ファイル: auth_test.py プロジェクト: dezynetechnologies/h
def test_groupfinder_calls_group_principals(models, groups):
    request = Mock()

    auth.groupfinder("jiji", request)

    groups.group_principals.assert_called_once_with(
        models.User.get_by_userid.return_value)
コード例 #2
0
def test_groupfinder_admin_and_staff(accounts):
    accounts.get_user.return_value = MagicMock(admin=True, staff=True)

    principals = auth.groupfinder("acct:[email protected]", Mock())

    assert "group:__admin__" in principals
    assert "group:__staff__" in principals
コード例 #3
0
ファイル: auth_test.py プロジェクト: dezynetechnologies/h
def test_groupfinder_admin_and_staff(models):
    request = MagicMock()
    models.User.get_by_userid.return_value = MagicMock(admin=True, staff=True)

    principals = auth.groupfinder("jiji", request)

    assert "group:__admin__" in principals
    assert "group:__staff__" in principals
コード例 #4
0
def test_groupfinder_returns_no_principals(accounts):
    """It should return only [] by default.

    If the request has no client and the user is not an admin or staff member
    nor a member of any group, it should return no additional principals.

    """
    accounts.get_user.return_value = MagicMock(admin=False, staff=False)

    assert auth.groupfinder("acct:[email protected]", Mock()) == []
コード例 #5
0
def test_groupfinder_with_three_groups(groups):
    groups.group_principals.return_value = [
        'group:group-1',
        'group:group-2',
        'group:group-3'
    ]

    additional_principals = auth.groupfinder("acct:[email protected]", Mock())

    assert 'group:group-1' in additional_principals
    assert 'group:group-2' in additional_principals
    assert 'group:group-3' in additional_principals
コード例 #6
0
ファイル: auth_test.py プロジェクト: dezynetechnologies/h
def test_groupfinder_returns_no_principals(models):
    """It should return only [] by default.

    If the request has no client and the user is not an admin or staff member
    nor a member of any group, it should return no additional principals.

    """
    request = MagicMock()
    models.User.get_by_userid.return_value = MagicMock(admin=False,
                                                       staff=False)

    assert auth.groupfinder("jiji", request) == []
コード例 #7
0
def test_groupfinder_with_one_group(groups):
    groups.group_principals.return_value = ['group:group-1']

    additional_principals = auth.groupfinder("acct:[email protected]", Mock())

    assert 'group:group-1' in additional_principals
コード例 #8
0
def test_groupfinder_calls_group_principals(accounts, groups):
    auth.groupfinder("acct:[email protected]", Mock())

    groups.group_principals.assert_called_once_with(
        accounts.get_user.return_value)
コード例 #9
0
def test_groupfinder_with_staff_user(accounts):
    """If the user is staff it should return a "group:__staff__" principal."""
    accounts.get_user.return_value = MagicMock(admin=False, staff=True)

    assert "group:__staff__" in auth.groupfinder(
        "acct:[email protected]", Mock())
コード例 #10
0
def test_groupfinder_with_admin_user(accounts):
    """If the user is an admin it should return "group:__admin__"."""
    accounts.get_user.return_value = MagicMock(admin=True, staff=False)

    assert "group:__admin__" in auth.groupfinder(
        "acct:[email protected]", Mock())
コード例 #11
0
ファイル: auth_test.py プロジェクト: dezynetechnologies/h
def test_groupfinder_with_staff_user(models):
    """If the user is staff it should return a "group:__staff__" principal."""
    request = MagicMock()
    models.User.get_by_userid.return_value = MagicMock(admin=False, staff=True)

    assert "group:__staff__" in auth.groupfinder("jiji", request)
コード例 #12
0
ファイル: auth_test.py プロジェクト: dezynetechnologies/h
def test_groupfinder_with_admin_user(models):
    """If the user is an admin it should return "group:__admin__"."""
    request = MagicMock()
    models.User.get_by_userid.return_value = MagicMock(admin=True, staff=False)

    assert "group:__admin__" in auth.groupfinder("jiji", request)