Exemple #1
0
def test_account_info(app, example_cern_openid):
    """Test account info extraction."""
    client = app.test_client()
    ioc = app.extensions['oauthlib.client']

    # Ensure remote apps have been loaded (due to before first request)
    client.get(url_for('invenio_oauthclient.login', remote_app='cern_openid'))

    example_response, _, example_account_info = example_cern_openid

    mock_remote_get(ioc, 'cern_openid', example_response)

    assert account_info(ioc.remote_apps['cern_openid'],
                        None) == example_account_info
Exemple #2
0
def test_account_info_not_allowed_account(app, example_cern_openid):
    """Test account info extraction."""
    client = app.test_client()

    app.config['OAUTHCLIENT_CERN_OPENID_ALLOWED_ROLES'] = ['another cern role']
    ioc = app.extensions['oauthlib.client']

    # Ensure remote apps have been loaded (due to before first request)
    client.get(url_for('invenio_oauthclient.login', remote_app='cern_openid'))

    example_response, _, example_account_info = example_cern_openid

    mock_remote_get(ioc, 'cern_openid', example_response)

    resp = account_info(ioc.remote_apps['cern_openid'], None)
    assert resp.status_code == 302
    assert session['_flashes'][0][0] == 'danger'
    assert session['_flashes'][0][1] == 'CERN account not allowed.'