From b3a48f2933ee7c0e1fabccfc29d9c0c34759b381 Mon Sep 17 00:00:00 2001 From: mire3212 Date: Wed, 24 Jul 2024 16:03:31 -0500 Subject: [PATCH 1/7] Updating test files to use new API endpoint. Adding config to pytest to help locate the project code. Removing some unused tests and updating some other tests that are referencing old or wrong error codes --- jupiterone/client.py | 7 +- setup.py | 3 +- tests/pytest.ini | 2 + tests/test_create_entity.py | 2 +- tests/test_create_relationship.py | 2 +- tests/test_delete_entity.py | 2 +- tests/test_delete_relationship.py | 2 +- tests/test_query.py | 102 ++++++++++++++++-------------- tests/test_update_entity.py | 2 +- 9 files changed, 66 insertions(+), 58 deletions(-) create mode 100644 tests/pytest.ini diff --git a/jupiterone/client.py b/jupiterone/client.py index 7cc185e..6312173 100644 --- a/jupiterone/client.py +++ b/jupiterone/client.py @@ -3,6 +3,7 @@ # see https://github.com/PyCQA/pylint/issues/409 import json +from warnings import warn from typing import Dict, List import requests @@ -50,11 +51,11 @@ def __init__(self, account: str = None, token: str = None, url: str = DEFAULT_UR self.account = account self.token = token self.url = url - self.query_endpoint = self.url + "/graphql" + self.query_endpoint = self.url self.rules_endpoint = self.url + "/rules/graphql" self.headers = { "Authorization": "Bearer {}".format(self.token), - "Jupiterone-Account": self.account, + "JupiterOne-Account": self.account, } @property @@ -124,7 +125,7 @@ def _execute_query(self, query: str, variables: Dict = None) -> Dict: raise JupiterOneApiRetryError("JupiterOne API rate limit exceeded.") elif response.status_code in [504]: - raise JupiterOneApiRetryError("Bad Gateway error. Check network route and try again.") + raise JupiterOneApiRetryError("Gateway Timeout.") elif response.status_code in [500]: raise JupiterOneApiError("JupiterOne API internal server error.") diff --git a/setup.py b/setup.py index 9cb3f2a..6cd952e 100644 --- a/setup.py +++ b/setup.py @@ -3,8 +3,7 @@ install_reqs = [ 'requests', - 'retrying', - 'warnings' + 'retrying' ] setup(name='jupiterone', diff --git a/tests/pytest.ini b/tests/pytest.ini new file mode 100644 index 0000000..8970bf4 --- /dev/null +++ b/tests/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +pythonpath = .. diff --git a/tests/test_create_entity.py b/tests/test_create_entity.py index 430a92e..b31b316 100644 --- a/tests/test_create_entity.py +++ b/tests/test_create_entity.py @@ -32,7 +32,7 @@ def request_callback(request): return (200, headers, json.dumps(response)) responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io', callback=request_callback, content_type='application/json', ) diff --git a/tests/test_create_relationship.py b/tests/test_create_relationship.py index 2bd4042..f63d4b5 100644 --- a/tests/test_create_relationship.py +++ b/tests/test_create_relationship.py @@ -36,7 +36,7 @@ def request_callback(request): return (200, headers, json.dumps(response)) responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io', callback=request_callback, content_type='application/json', ) diff --git a/tests/test_delete_entity.py b/tests/test_delete_entity.py index 02e5d18..73348a1 100644 --- a/tests/test_delete_entity.py +++ b/tests/test_delete_entity.py @@ -33,7 +33,7 @@ def request_callback(request): return (200, headers, json.dumps(response)) responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io', callback=request_callback, content_type='application/json', ) diff --git a/tests/test_delete_relationship.py b/tests/test_delete_relationship.py index 16995d4..42493b3 100644 --- a/tests/test_delete_relationship.py +++ b/tests/test_delete_relationship.py @@ -36,7 +36,7 @@ def request_callback(request): return (200, headers, json.dumps(response)) responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io', callback=request_callback, content_type='application/json', ) diff --git a/tests/test_query.py b/tests/test_query.py index 28dbc58..ff58bf9 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -5,7 +5,10 @@ from jupiterone.client import JupiterOneClient from jupiterone.constants import QUERY_V1 -from jupiterone.errors import JupiterOneApiError +from jupiterone.errors import ( + JupiterOneApiRetryError, + JupiterOneApiError +) def build_results(response_code: int = 200, cursor: str = None, max_pages: int = 1): pages = Counter(requests=0) @@ -74,9 +77,8 @@ def request_callback(request): @responses.activate def test_execute_query(): - responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_results(), content_type='application/json', ) @@ -103,7 +105,7 @@ def test_execute_query(): def test_limit_skip_query_v1(): responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_results(), content_type='application/json', ) @@ -125,13 +127,13 @@ def test_limit_skip_query_v1(): def test_cursor_query_v1(): responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_results(cursor='cursor_value'), content_type='application/json', ) responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_results(), content_type='application/json', ) @@ -177,7 +179,7 @@ def request_callback(request): return (200, headers, json.dumps(response)) responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=request_callback, content_type='application/json', ) @@ -226,7 +228,7 @@ def request_callback(request): return (200, headers, json.dumps(response)) responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=request_callback, content_type='application/json', ) @@ -245,19 +247,19 @@ def request_callback(request): @responses.activate def test_retry_on_limit_skip_query(): responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_results(response_code=429), content_type='application/json', ) responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_results(response_code=503), content_type='application/json', ) responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_results(), content_type='application/json', ) @@ -278,19 +280,19 @@ def test_retry_on_limit_skip_query(): @responses.activate def test_retry_on_cursor_query(): responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_results(response_code=429), content_type='application/json', ) responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_results(response_code=503), content_type='application/json', ) responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_results(), content_type='application/json', ) @@ -309,7 +311,7 @@ def test_retry_on_cursor_query(): @responses.activate def test_avoid_retry_on_limit_skip_query(): responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_results(response_code=404), content_type='application/json', ) @@ -326,7 +328,7 @@ def test_avoid_retry_on_limit_skip_query(): @responses.activate def test_avoid_retry_on_cursor_query(): responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_results(response_code=404), content_type='application/json', ) @@ -341,7 +343,7 @@ def test_avoid_retry_on_cursor_query(): @responses.activate def test_warn_limit_and_skip_deprecated(): responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_results(), content_type='application/json', ) @@ -360,7 +362,7 @@ def test_warn_limit_and_skip_deprecated(): @responses.activate def test_unauthorized_query_v1(): responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_error_results(401, b'Unauthorized', 'text/plain'), content_type='application/json', ) @@ -371,14 +373,13 @@ def test_unauthorized_query_v1(): with pytest.raises(JupiterOneApiError) as exc_info: j1.query_v1(query) - assert exc_info.value.args[0] == 'JupiterOne API query is unauthorized, check credentials.' - + assert "401: Unauthorized" in str(exc_info.value.args[0]) @responses.activate -def test_unexpected_string_error_query_v1(): +def test_five_hundred_error_query_v1(): responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', - callback=build_error_results(500, 'String exception on server', 'text/plain'), + responses.POST, 'https://graphql.us.jupiterone.io/', + callback=build_error_results(500, 'Internal Server Error', 'text/plain'), content_type='application/json', ) @@ -388,17 +389,17 @@ def test_unexpected_string_error_query_v1(): with pytest.raises(JupiterOneApiError) as exc_info: j1.query_v1(query) - assert exc_info.value.args[0] == '500:String exception on server' + assert exc_info.value.args[0] == 'JupiterOne API internal server error.' @responses.activate -def test_unexpected_json_error_query_v1(): +def test_bad_gateway_error_query_v1(): error_json = { 'error': 'Bad Gateway' } responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io/', callback=build_error_results(502, json.dumps(error_json), ), content_type='application/json', ) @@ -409,25 +410,30 @@ def test_unexpected_json_error_query_v1(): with pytest.raises(JupiterOneApiError) as exc_info: j1.query_v1(query) - assert exc_info.value.args[0] == '502:Bad Gateway' - - -@responses.activate -def test_unexpected_json_errors_query_v1(): - errors_json = { - 'errors': ['First error', 'Second error', 'Third error'] - } - - responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', - callback=build_error_results(500, json.dumps(errors_json), ), - content_type='application/json', - ) - - j1 = JupiterOneClient(account='testAccount', token='bogusToken') - query = "find Host with _id='1' return tree" - - with pytest.raises(JupiterOneApiError) as exc_info: - j1.query_v1(query) - - assert exc_info.value.args[0] == "500:['First error', 'Second error', 'Third error']" +# @responses.activate +# def test_rate_limit_error_query_v1(): +# responses.add_callback( +# responses.POST, 'https://graphql.us.jupiterone.io/', +# callback=build_error_results(429, "Too Many Requests", ), +# content_type='application/json', +# ) + +# j1 = JupiterOneClient(account='testAccount', token='bogusToken') +# query = "find Host with _id='1' return tree" + +# with pytest.raises(JupiterOneApiError) as exc_info: +# j1.query_v1(query) + +# @responses.activate +# def test_service_unavailable_error_query_v1(): +# responses.add_callback( +# responses.POST, 'https://graphql.us.jupiterone.io/', +# callback=build_error_results(503, "Service Unavailable", ), +# content_type='application/json', +# ) + +# j1 = JupiterOneClient(account='testAccount', token='bogusToken') +# query = "find Host with _id='1' return tree" + +# with pytest.raises(JupiterOneApiRetryError) as exc_info: +# j1.query_v1(query) diff --git a/tests/test_update_entity.py b/tests/test_update_entity.py index f6bb6ce..cbd24c3 100644 --- a/tests/test_update_entity.py +++ b/tests/test_update_entity.py @@ -29,7 +29,7 @@ def request_callback(request): return (200, headers, json.dumps(response)) responses.add_callback( - responses.POST, 'https://api.us.jupiterone.io/graphql', + responses.POST, 'https://graphql.us.jupiterone.io', callback=request_callback, content_type='application/json', ) From 3b596d8df9891d798d8c68276c350305f9fb4bf0 Mon Sep 17 00:00:00 2001 From: SeaBlooms Date: Tue, 30 Jul 2024 06:09:40 -0600 Subject: [PATCH 2/7] Update client.py --- jupiterone/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jupiterone/client.py b/jupiterone/client.py index 6312173..4b3bdb5 100644 --- a/jupiterone/client.py +++ b/jupiterone/client.py @@ -91,7 +91,7 @@ def _execute_query(self, query: str, variables: Dict = None) -> Dict: if variables: data.update(variables=variables) - # Always ask for variableresultsize + # Always ask for variableResultSize data.update(flags={"variableResultSize": True}) response = requests.post( From 50e793f5ce14bd4b91751726bc699e0269bf78fa Mon Sep 17 00:00:00 2001 From: SeaBlooms Date: Tue, 30 Jul 2024 08:27:59 -0600 Subject: [PATCH 3/7] PEP8 fixes --- tests/test_query.py | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/tests/test_query.py b/tests/test_query.py index ff58bf9..14b377b 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -10,6 +10,7 @@ JupiterOneApiError ) + def build_results(response_code: int = 200, cursor: str = None, max_pages: int = 1): pages = Counter(requests=0) @@ -60,7 +61,7 @@ def request_callback(request): pages.update(requests=1) - return (response_code, headers, json.dumps(response)) + return response_code, headers, json.dumps(response) return request_callback @@ -97,7 +98,7 @@ def test_execute_query(): assert 'data' in response assert 'queryV1' in response['data'] assert len(response['data']['queryV1']['data']) == 1 - assert type(response['data']['queryV1']['data']) == list + assert type(response['data']['queryV1']['data']) is list assert response['data']['queryV1']['data'][0]['entity']['_id'] == '1' @@ -118,11 +119,12 @@ def test_limit_skip_query_v1(): skip=0 ) - assert type(response) == dict + assert type(response) is dict assert len(response['data']) == 1 - assert type(response['data']) == list + assert type(response['data']) is list assert response['data'][0]['entity']['_id'] == '1' + @responses.activate def test_cursor_query_v1(): @@ -145,11 +147,12 @@ def test_cursor_query_v1(): query=query, ) - assert type(response) == dict + assert type(response) is dict assert len(response['data']) == 2 - assert type(response['data']) == list + assert type(response['data']) is list assert response['data'][0]['entity']['_id'] == '1' + @responses.activate def test_limit_skip_tree_query_v1(): @@ -176,7 +179,7 @@ def request_callback(request): } } - return (200, headers, json.dumps(response)) + return 200, headers, json.dumps(response) responses.add_callback( responses.POST, 'https://graphql.us.jupiterone.io/', @@ -192,13 +195,14 @@ def request_callback(request): skip=0 ) - assert type(response) == dict + assert type(response) is dict assert 'edges' in response assert 'vertices' in response - assert type(response['edges']) == list - assert type(response['vertices']) == list + assert type(response['edges']) is list + assert type(response['vertices']) is list assert response['vertices'][0]['id'] == '1' + @responses.activate def test_cursor_tree_query_v1(): @@ -237,13 +241,14 @@ def request_callback(request): query = "find Host with _id='1' return tree" response = j1.query_v1(query) - assert type(response) == dict + assert type(response) is dict assert 'edges' in response assert 'vertices' in response - assert type(response['edges']) == list - assert type(response['vertices']) == list + assert type(response['edges']) is list + assert type(response['vertices']) is list assert response['vertices'][0]['id'] == '1' + @responses.activate def test_retry_on_limit_skip_query(): responses.add_callback( @@ -272,11 +277,12 @@ def test_retry_on_limit_skip_query(): skip=0 ) - assert type(response) == dict + assert type(response) is dict assert len(response['data']) == 1 - assert type(response['data']) == list + assert type(response['data']) is list assert response['data'][0]['entity']['_id'] == '1' + @responses.activate def test_retry_on_cursor_query(): responses.add_callback( @@ -303,11 +309,12 @@ def test_retry_on_cursor_query(): query=query ) - assert type(response) == dict + assert type(response) is dict assert len(response['data']) == 1 - assert type(response['data']) == list + assert type(response['data']) is list assert response['data'][0]['entity']['_id'] == '1' + @responses.activate def test_avoid_retry_on_limit_skip_query(): responses.add_callback( @@ -325,6 +332,7 @@ def test_avoid_retry_on_limit_skip_query(): skip=0 ) + @responses.activate def test_avoid_retry_on_cursor_query(): responses.add_callback( @@ -340,6 +348,7 @@ def test_avoid_retry_on_cursor_query(): query=query ) + @responses.activate def test_warn_limit_and_skip_deprecated(): responses.add_callback( @@ -375,6 +384,7 @@ def test_unauthorized_query_v1(): assert "401: Unauthorized" in str(exc_info.value.args[0]) + @responses.activate def test_five_hundred_error_query_v1(): responses.add_callback( From daed9a56189920d2138b11a2c61d45dae7eb3280 Mon Sep 17 00:00:00 2001 From: SeaBlooms Date: Wed, 31 Jul 2024 15:31:50 -0600 Subject: [PATCH 4/7] Update test_query.py --- tests/test_query.py | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/tests/test_query.py b/tests/test_query.py index 14b377b..6bad928 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -419,31 +419,3 @@ def test_bad_gateway_error_query_v1(): with pytest.raises(JupiterOneApiError) as exc_info: j1.query_v1(query) - -# @responses.activate -# def test_rate_limit_error_query_v1(): -# responses.add_callback( -# responses.POST, 'https://graphql.us.jupiterone.io/', -# callback=build_error_results(429, "Too Many Requests", ), -# content_type='application/json', -# ) - -# j1 = JupiterOneClient(account='testAccount', token='bogusToken') -# query = "find Host with _id='1' return tree" - -# with pytest.raises(JupiterOneApiError) as exc_info: -# j1.query_v1(query) - -# @responses.activate -# def test_service_unavailable_error_query_v1(): -# responses.add_callback( -# responses.POST, 'https://graphql.us.jupiterone.io/', -# callback=build_error_results(503, "Service Unavailable", ), -# content_type='application/json', -# ) - -# j1 = JupiterOneClient(account='testAccount', token='bogusToken') -# query = "find Host with _id='1' return tree" - -# with pytest.raises(JupiterOneApiRetryError) as exc_info: -# j1.query_v1(query) From 1535dd2c99d46cf2c9e5f2393fe2fa00667a230a Mon Sep 17 00:00:00 2001 From: SeaBlooms Date: Wed, 31 Jul 2024 15:33:40 -0600 Subject: [PATCH 5/7] Update test_query.py --- tests/test_query.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_query.py b/tests/test_query.py index 6bad928..c2f2961 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -6,7 +6,6 @@ from jupiterone.client import JupiterOneClient from jupiterone.constants import QUERY_V1 from jupiterone.errors import ( - JupiterOneApiRetryError, JupiterOneApiError ) From 0293a06669f30735bbeaf3cd3023754b46dbd29f Mon Sep 17 00:00:00 2001 From: SeaBlooms Date: Wed, 31 Jul 2024 15:35:01 -0600 Subject: [PATCH 6/7] Update test_query.py --- tests/test_query.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_query.py b/tests/test_query.py index c2f2961..d8b0b28 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -5,9 +5,7 @@ from jupiterone.client import JupiterOneClient from jupiterone.constants import QUERY_V1 -from jupiterone.errors import ( - JupiterOneApiError -) +from jupiterone.errors import JupiterOneApiError def build_results(response_code: int = 200, cursor: str = None, max_pages: int = 1): From d06b656ba48f18e785963690186b923852f92c8f Mon Sep 17 00:00:00 2001 From: SeaBlooms Date: Wed, 31 Jul 2024 15:36:48 -0600 Subject: [PATCH 7/7] Update test_query.py --- tests/test_query.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/test_query.py b/tests/test_query.py index d8b0b28..ccff7ef 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -76,7 +76,7 @@ def request_callback(request): @responses.activate def test_execute_query(): responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_results(), content_type='application/json', ) @@ -103,7 +103,7 @@ def test_execute_query(): def test_limit_skip_query_v1(): responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_results(), content_type='application/json', ) @@ -126,13 +126,13 @@ def test_limit_skip_query_v1(): def test_cursor_query_v1(): responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_results(cursor='cursor_value'), content_type='application/json', ) responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_results(), content_type='application/json', ) @@ -179,7 +179,7 @@ def request_callback(request): return 200, headers, json.dumps(response) responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=request_callback, content_type='application/json', ) @@ -229,7 +229,7 @@ def request_callback(request): return (200, headers, json.dumps(response)) responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=request_callback, content_type='application/json', ) @@ -249,19 +249,19 @@ def request_callback(request): @responses.activate def test_retry_on_limit_skip_query(): responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_results(response_code=429), content_type='application/json', ) responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_results(response_code=503), content_type='application/json', ) responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_results(), content_type='application/json', ) @@ -283,19 +283,19 @@ def test_retry_on_limit_skip_query(): @responses.activate def test_retry_on_cursor_query(): responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_results(response_code=429), content_type='application/json', ) responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_results(response_code=503), content_type='application/json', ) responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_results(), content_type='application/json', ) @@ -315,7 +315,7 @@ def test_retry_on_cursor_query(): @responses.activate def test_avoid_retry_on_limit_skip_query(): responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_results(response_code=404), content_type='application/json', ) @@ -333,7 +333,7 @@ def test_avoid_retry_on_limit_skip_query(): @responses.activate def test_avoid_retry_on_cursor_query(): responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_results(response_code=404), content_type='application/json', ) @@ -349,7 +349,7 @@ def test_avoid_retry_on_cursor_query(): @responses.activate def test_warn_limit_and_skip_deprecated(): responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_results(), content_type='application/json', ) @@ -368,7 +368,7 @@ def test_warn_limit_and_skip_deprecated(): @responses.activate def test_unauthorized_query_v1(): responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_error_results(401, b'Unauthorized', 'text/plain'), content_type='application/json', ) @@ -385,7 +385,7 @@ def test_unauthorized_query_v1(): @responses.activate def test_five_hundred_error_query_v1(): responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_error_results(500, 'Internal Server Error', 'text/plain'), content_type='application/json', ) @@ -406,7 +406,7 @@ def test_bad_gateway_error_query_v1(): } responses.add_callback( - responses.POST, 'https://graphql.us.jupiterone.io/', + responses.POST, 'https://graphql.us.jupiterone.io', callback=build_error_results(502, json.dumps(error_json), ), content_type='application/json', )