コード例 #1
0
def test_get_permitted_operations(
    mocked_get_groups,
    expected_operations,
    owner_name,
    owner_groups,
    user_name,
    user_groups,
):
    mocked_get_groups.side_effect = [(owner_groups, []), (user_groups, [])]
    auth_obj = Authorization(owner_name, FAKE_USER_CONF, FAKE_SITE_CONF, log)
    actual_operations = auth_obj.get_permitted_operations(
        access_user=user_name)
    assert actual_operations == expected_operations
コード例 #2
0
def test_is_permitted(
    mocked_get_groups,
    owner_name,
    user_name,
    get_permitted_operations_is_called,
    expected,
):
    mocked_get_groups.side_effect = [([""], []), ([""], [])]
    auth_obj = Authorization(owner_name, FAKE_USER_CONF, FAKE_SITE_CONF, log)
    auth_obj.get_permitted_operations = Mock(return_value=["fake_operation"])
    actual = auth_obj.is_permitted(access_user=user_name,
                                   operation="fake_operation")
    if get_permitted_operations_is_called:
        auth_obj.get_permitted_operations.assert_called_with(user_name)
    assert actual == expected