def test_account_info(app, example_cern): """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')) example_response, _, example_account_info = example_cern mock_remote_get(ioc, 'cern', example_response) assert account_info( ioc.remote_apps['cern'], None) == example_account_info assert account_info(ioc.remote_apps['cern'], {}) == \ dict( user=dict( email='*****@*****.**', profile={ 'full_name': u'Test Account', 'username': u'taccount' }, ), external_id='123456', external_method="cern", active=True )
def test_account_info(app, example_cern): """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')) example_response, _, example_account_info = example_cern mock_remote_get(ioc, 'cern', example_response) assert account_info(ioc.remote_apps['cern'], None) == example_account_info assert account_info(ioc.remote_apps['cern'], {}) == \ dict( user=dict( email='*****@*****.**', profile={ 'full_name': u'Test Account', 'username': u'taccount' }, ), external_id='123456', external_method='cern', active=True )
def test_account_info_not_allowed_account(app, example_cern): """Test account info extraction.""" client = app.test_client() app.config['OAUTHCLIENT_CERN_ALLOWED_IDENTITY_CLASSES'] = [ 'another cern type' ] 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')) example_response, _, example_account_info = example_cern mock_remote_get(ioc, 'cern', example_response) with pytest.raises(OAuthCERNRejectedAccountError): account_info(ioc.remote_apps['cern'], None)
def test_account_info_not_allowed_account(app, example_cern): """Test account info extraction.""" client = app.test_client() app.config['OAUTHCLIENT_CERN_ALLOWED_IDENTITY_CLASSES'] = [ 'another cern type' ] 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')) example_response, _, example_account_info = example_cern mock_remote_get(ioc, 'cern', example_response) resp = account_info(ioc.remote_apps['cern'], None) assert resp.status_code == 302 assert session['_flashes'][0][0] == 'danger' assert session['_flashes'][0][1] == 'CERN account not allowed.'