def test_fetch_groups(app, example_cern):
    """Test group extraction."""
    example_response, example_token, _ = example_cern
    res = get_dict_from_response(example_response)

    # Override hidden group configuration
    import re
    cern.CFG_EXTERNAL_AUTH_HIDDEN_GROUPS = ('hidden_group',)
    cern.CFG_EXTERNAL_AUTH_HIDDEN_GROUPS_RE = (re.compile(r'Group[1-3]'),)

    # Check that groups were hidden as required
    groups = fetch_groups(res['Group'])
    assert all(group in groups
               for group in ('Group{}'.format(i) for i in range(4, 6)))
Esempio n. 2
0
def test_fetch_groups(app, example_cern):
    """Test group extraction."""
    example_response, example_token, _ = example_cern
    res = get_dict_from_response(example_response)

    # Override hidden group configuration
    import re
    app.config['OAUTHCLIENT_CERN_HIDDEN_GROUPS'] = ('hidden_group', )
    app.config['OAUTHCLIENT_CERN_HIDDEN_GROUPS_RE'] = (
        re.compile(r'Group[1-3]'), )

    # Check that groups were hidden as required
    groups = fetch_groups(res['Group'])
    assert all(group in groups
               for group in ('Group{}'.format(i) for i in range(4, 6)))