def test_account_info(app_rest, example_cern): """Test account info extraction.""" client = app_rest.test_client() ioc = app_rest.extensions['oauthlib.client'] # Ensure remote apps have been loaded (due to before first request) client.get(url_for('invenio_oauthclient.rest_login', remote_app='cern')) example_response, _, example_account_info = example_cern mock_remote_get(ioc, 'cern', example_response) assert account_info_rest( ioc.remote_apps['cern'], None) == example_account_info assert account_info_rest(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_rest, example_cern): """Test account info extraction.""" client = app_rest.test_client() ioc = app_rest.extensions['oauthlib.client'] # Ensure remote apps have been loaded (due to before first request) client.get(url_for('invenio_oauthclient.rest_login', remote_app='cern')) example_response, _, example_account_info = example_cern mock_remote_get(ioc, 'cern', example_response) assert account_info_rest( ioc.remote_apps['cern'], None) == example_account_info
def test_account_info_not_allowed_account(app_rest, example_cern): """Test account info extraction.""" client = app_rest.test_client() app_rest.config['OAUTHCLIENT_CERN_ALLOWED_IDENTITY_CLASSES'] = [ 'another cern type' ] ioc = app_rest.extensions['oauthlib.client'] # Ensure remote apps have been loaded (due to before first request) client.get(url_for('invenio_oauthclient.rest_login', remote_app='cern')) example_response, _, example_account_info = example_cern mock_remote_get(ioc, 'cern', example_response) resp = account_info_rest(ioc.remote_apps['cern'], None) assert resp.status_code == 302 expected_url_args = { "message": "CERN account not allowed.", "code": 400, } check_response_redirect_url_args(resp, expected_url_args)