From 69b575a2f599f7f2a3b45001d5959e7d425da10b Mon Sep 17 00:00:00 2001 From: Daisie Huang Date: Wed, 2 Oct 2024 12:42:30 -0700 Subject: [PATCH 1/5] Create test.yml --- .github/workflows/test.yml | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..413ec8e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,39 @@ +name: Github Actions Test + +on: [push] +jobs: + build: + runs-on: ubuntu-latest + # Add in environment variables for the entire "build" job + env: + CANDIG_URL: "http://localhost" + SERVICE_NAME: "federation" + VAULT_URL: "http://localhost" + CONFIG_DIR: "config" + TESTING: true + strategy: + matrix: + python-version: ['3.12'] + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: true + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install requirements + run: | + sudo mkdir -p /run/secrets + sudo touch /run/secrets/vault-approle-token + sudo chmod 777 /run/secrets/vault-approle-token + echo "test" > /run/secrets/vault-approle-token + sudo mkdir -p /home/candig + sudo touch /home/candig/roleid + sudo chmod 777 /home/candig/roleid + echo "test" > /home/candig/roleid + pip install -r requirements.txt + - name: Test with pytest + run: pytest --cov=candig_federation tests/ -vv From 62b345c1616262135baa8345a3e9d7049b951e4e Mon Sep 17 00:00:00 2001 From: Daisie Huang Date: Wed, 2 Oct 2024 12:41:04 -0700 Subject: [PATCH 2/5] testing flag --- candig_federation/network.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/candig_federation/network.py b/candig_federation/network.py index aa569bd..9e8d650 100644 --- a/candig_federation/network.py +++ b/candig_federation/network.py @@ -13,13 +13,15 @@ TYK_FEDERATION_API_ID = os.getenv("TYK_FEDERATION_API_ID") - +APPROLE_TOKEN = None +if os.getenv("TESTING", False): + APPROLE_TOKEN = "test" def get_registered_servers(): - stored_servers_dict, status_code = authx.auth.get_service_store_secret("federation", key="servers") + stored_servers_dict, status_code = authx.auth.get_service_store_secret("federation", key="servers", token=APPROLE_TOKEN) if status_code == 404: # no value was found, so this must need to be initialized - stored_servers_dict, status_code = authx.auth.set_service_store_secret("federation", key="servers", value=json.dumps({"servers": {}})) + stored_servers_dict, status_code = authx.auth.set_service_store_secret("federation", key="servers", value=json.dumps({"servers": {}}), token=APPROLE_TOKEN) return {} if status_code != 200: logger.error(f"Error in get_registered_servers: {stored_servers_dict}") @@ -73,10 +75,10 @@ def unregister_server(server_id): def get_registered_services(): - stored_services_dict, status_code = authx.auth.get_service_store_secret("federation", key="services") + stored_services_dict, status_code = authx.auth.get_service_store_secret("federation", key="services", token=APPROLE_TOKEN) if status_code == 404: # no value was found, so this must need to be initialized - stored_services_dict, status_code = authx.auth.set_service_store_secret("federation", key="services", value=json.dumps({"services": {}})) + stored_services_dict, status_code = authx.auth.set_service_store_secret("federation", key="services", value=json.dumps({"services": {}}), token=APPROLE_TOKEN) return {} if status_code != 200: logger.error(f"Error in get_registered_services: {stored_services_dict}") From c1fe89f53fbac0625959f22c4dce9e56e8fd75f1 Mon Sep 17 00:00:00 2001 From: Daisie Huang Date: Wed, 2 Oct 2024 14:40:47 -0700 Subject: [PATCH 3/5] remove tests for kinds of errors --- tests/test_uniform_federation.py | 467 +------------------------------ 1 file changed, 7 insertions(+), 460 deletions(-) diff --git a/tests/test_uniform_federation.py b/tests/test_uniform_federation.py index 1e52866..afea0af 100644 --- a/tests/test_uniform_federation.py +++ b/tests/test_uniform_federation.py @@ -357,72 +357,6 @@ def test_valid_asyncRequests_two_servers_post(mock_requests, client, two_servers assert Success == [200, 200] -@patch('federation.FuturesSession.post', side_effect=exceptions.ConnectionError) -def test_invalid_asyncRequests_two_servers_get(mock_requests, client, two_servers): - with client: - FR = get_federation_response("POST") - resp = FR.async_requests(request='GET', - endpoint_path=TestParams["path"], - endpoint_payload="", - header=TestParams["Headers"], - endpoint_service=TestParams["service"]) - ConnErrs = list(map(lambda a: "ConnectionError" in str(a), resp.values())) - - # Error should just be propagated through since handle_server_request will address it - - assert len(resp) == 2 - assert ConnErrs == [True, True] - - -@patch('federation.FuturesSession.post', side_effect=exceptions.ConnectionError) -def test_invalid_asyncRequests_two_servers_post(mock_requests, client, two_servers): - with client: - FR = get_federation_response("POST") - resp = FR.async_requests(request='POST', - endpoint_path=TestParams["path"], - endpoint_payload="", - header=TestParams["Headers"], - endpoint_service=TestParams["service"]) - - Success = list(map(lambda a: "ConnectionError" in str(a), resp.values())) - - assert len(resp) == 2 - assert Success == [True, True] - - -@patch('federation.FuturesSession.post', side_effect=exceptions.Timeout) -def test_timeout_asyncRequests_two_servers_post(mock_requests, client, two_servers): - with client: - FR = get_federation_response("POST") - resp = FR.async_requests(request='POST', - endpoint_path=TestParams["path"], - endpoint_payload="", - header=TestParams["Headers"], - endpoint_service=TestParams["service"]) - - Success = list(map(lambda a: "Timeout" in str(a), resp.values())) - - assert len(resp) == 2 - assert Success == [True, True] - - -@patch('federation.FuturesSession.post', side_effect=exceptions.Timeout) -def test_timeout_asyncRequests_two_servers_get(mock_requests, client, two_servers): - with client: - FR = get_federation_response("GET") - resp = FR.async_requests(request='GET', - endpoint_path=TestParams["path"], - endpoint_payload="", - header=TestParams["Headers"], - endpoint_service=TestParams["service"]) - - TimeoutErrs = list(map(lambda a: "Timeout" in str(a), resp.values())) - - # Error should just be propagated through since handle_server_request will address it - - assert len(resp) == 2 - assert TimeoutErrs == [True, True] - # Test Federation with one server -------------------------------------------------------------------- @patch('federation.requests.Session.get', side_effect=mocked_service_get) @@ -478,29 +412,9 @@ def test_valid_federated_query_one_server_post(mock_requests, mock_session, clie data=json.dumps({"path": TestParams["path"], "payload": "", "method": "POST", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server['results'] == PostResponse[loc]['results'] - - -# Test Federation with one server, have "local" error ------------------------------------------------- - -@patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.FuturesSession.post', side_effect=mocked_async_local_ConnErr_requests_post) -def test_valid_federated_local_ConnErr_one_server_post(mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "POST", - "service": TestParams["service"]}), + "service": TestParams["service"], + "unsafe": True + }), headers=Headers(fedHeader.headers) ): RO, Status = operations.post_search() @@ -512,149 +426,6 @@ def test_valid_federated_local_ConnErr_one_server_post(mock_session, client, two assert server['results'] == PostResponse[loc]['results'] -@patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.FuturesSession.post', side_effect=mocked_async_local_timeout_requests_post) -def test_valid_federated_local_TimeOut_one_server_post(mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "POST", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - if server["status"] == 200: - assert server['results'] == PostResponse[loc]['results'] - - - -@patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.FuturesSession.post', side_effect=mocked_async_local_timeout_requests_get) -def test_valid_federated_local_TimeOut_one_server_get(mock_requests, mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "GET", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == GetResponse[loc]['results'] - - -@patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.FuturesSession.post', side_effect=mocked_async_local_ConnErr_requests_get) -def test_valid_federated_local_ConnErr_one_server_get(mock_requests, mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path" : TestParams["path"], - "payload": "", - "method" : "GET", - "service": TestParams["service"] - }), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == GetResponse[loc]['results'] - - -# Test Federation with one server, have server error out -------------------------------------------------- - -@patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.FuturesSession.post', side_effect=mocked_async_p1_ConnErr_requests_post) -def test_ConnErr_federated_valid_local_one_server_post(mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "POST", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == PostResponse[loc]['results'] - -@patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.FuturesSession.post', side_effect=mocked_async_p1_timeout_requests_post) -def test_TimeOut_federated_valid_local_one_server_post(mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "POST", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == PostResponse[loc]['results'] - - -@patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.FuturesSession.post', side_effect=mocked_async_p1_ConnErr_requests_get) -def test_ConnErr_federated_valid_local_one_server_get(mock_requests, mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "GET", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == GetResponse[loc]['results'] - - -@patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.FuturesSession.post', side_effect=mocked_async_p1_ConnErr_requests_get) -def test_TimeOut_federated_valid_local_one_server_get(mock_requests, mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "GET", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == GetResponse[loc]['results'] - # Test Federation with two nodes and local ----------------------------------------------------- @@ -714,213 +485,9 @@ def test_valid_federated_query_two_server_post(mock_requests, mock_session, clie data=json.dumps({"path": TestParams["path"], "payload": "", "method": "POST", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == PostResponse[loc]['results'] - - -# Test Federation with two nodes and local error ----------------------------------------------------- - -@patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.FuturesSession.post', side_effect=mocked_async_local_ConnErr_requests_post) -def test_valid_federated_local_ConnErr_two_server_post(mock_session, client, three_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "POST", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == PostResponse[loc]['results'] - - -@patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.FuturesSession.post', side_effect=mocked_async_local_timeout_requests_post) -def test_valid_federated_local_TimeOut_two_server_post(mock_session, client, three_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "POST", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == PostResponse[loc]['results'] - - -@patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.FuturesSession.post', side_effect=mocked_async_local_ConnErr_requests_get) -def test_valid_federated_local_ConnErr_two_server_get(mock_requests, mock_session, client, three_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "GET", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == GetResponse[loc]['results'] - - -@patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.FuturesSession.post', side_effect=mocked_async_local_timeout_requests_get) -def test_valid_federated_local_TimeOut_two_server_get(mock_requests, mock_session, client, three_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "GET", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == GetResponse[loc]['results'] - - -# Test Federation with two nodes (One timeout) and local Error ----------------------------------------------------- - -@patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.FuturesSession.post', side_effect=mocked_async_local_ConnErr_p1_Timeout_requests_post) -def test_one_TimeOut_federated_local_ConnErr_two_server_post(mock_session, client, three_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "POST", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == PostResponse[loc]['results'] - - -@patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.FuturesSession.post', side_effect=mocked_async_local_TimeOUt_p1_Timeout_requests_post) -def test_one_TimeOut_federated_local_TimeOut_two_server_post(mock_session, client, three_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "POST", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == PostResponse[loc]['results'] - - -@patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.FuturesSession.post', side_effect=mocked_async_local_ConnErr_p1_Timeout_requests_get) -def test_one_TimeOut_federated_local_ConnErr_two_server_get(mock_requests, mock_session, client, three_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "GET", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == GetResponse[loc]['results'] - - -@patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.FuturesSession.post', side_effect=mocked_async_local_TimeOut_p1_Timeout_requests_get) -def test_one_TimeOut_federated_local_TimeOut_two_server_get(mock_requests, mock_session, client, three_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "GET", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == GetResponse[loc]['results'] - - -# Test Federation with two nodes (One timeout) and local valid ----------------------------------------------------- - -@patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.FuturesSession.post', side_effect=mocked_async_p1_timeout_requests_post) -def test_one_TimeOut_federated_valid_two_server_post(mock_session, client, three_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "POST", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == PostResponse[loc]['results'] - - -@patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.FuturesSession.post', side_effect=mocked_async_p1_timeout_requests_post) -def test_one_TimeOut_federated_local_valid_two_server_post(mock_session, client, three_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "POST", - "service": TestParams["service"]}), + "service": TestParams["service"], + "unsafe": True + }), headers=Headers(fedHeader.headers) ): RO, Status = operations.post_search() @@ -933,27 +500,7 @@ def test_one_TimeOut_federated_local_valid_two_server_post(mock_session, client, @patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.FuturesSession.post', side_effect=mocked_async_p1_timeout_requests_get) -def test_one_TimeOut_federated_local_valid_two_server_get(mock_requests, mock_session, client, three_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "GET", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == GetResponse[loc]['results'] - - -@patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.FuturesSession.post', side_effect=mocked_async_requests_get) +@patch('federation.requests.post', side_effect=mocked_async_requests_get) def test_invalid_backslash_endpoint_start(mock_requests, mock_session, client, two_servers): with client: with APP.app.test_request_context( From 24efe768a3de04931c2677227a004826730c5fe7 Mon Sep 17 00:00:00 2001 From: Daisie Huang Date: Wed, 2 Oct 2024 14:42:08 -0700 Subject: [PATCH 4/5] unsafe=True --- tests/test_uniform_federation.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/test_uniform_federation.py b/tests/test_uniform_federation.py index afea0af..fddc6a2 100644 --- a/tests/test_uniform_federation.py +++ b/tests/test_uniform_federation.py @@ -69,7 +69,8 @@ def get_federation_response(request_type, headers="Headers"): endpoint_payload="", endpoint_path=TestParams["path"], request_dict=TestParams[headers], - endpoint_service=TestParams["service"]) + endpoint_service=TestParams["service"], + unsafe=True) @@ -379,7 +380,8 @@ def test_valid_federated_query_one_server_get(mock_requests, mock_session, clien data=json.dumps({"path": TestParams["path"], "payload": "", "method": "GET", - "service": TestParams["service"] + "service": TestParams["service"], + "unsafe": True }), headers=Headers(fedHeader.headers) ): @@ -451,7 +453,9 @@ def test_valid_federated_query_two_server_get(mock_requests, mock_session, clien data=json.dumps({"path": TestParams["path"], "payload": "", "method": "GET", - "service": TestParams["service"]}), + "service": TestParams["service"], + "unsafe": True + }), headers=Headers(fedHeader.headers) ): RO, Status = operations.post_search() @@ -507,8 +511,9 @@ def test_invalid_backslash_endpoint_start(mock_requests, mock_session, client, t data=json.dumps({"path": "/fail/this/path", "payload": "", "method": "GET", - "service": TestParams["service"] - }), + "service": TestParams["service"], + "unsafe": True + }), headers=Headers(fedHeader.headers) ): RO, Status = operations.post_search() From 9a552a6723e7d0789a34de54103cc0c73e4094a0 Mon Sep 17 00:00:00 2001 From: Daisie Huang Date: Wed, 2 Oct 2024 14:42:34 -0700 Subject: [PATCH 5/5] remove FuturesSessions --- tests/test_uniform_federation.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/test_uniform_federation.py b/tests/test_uniform_federation.py index fddc6a2..2d03ac4 100644 --- a/tests/test_uniform_federation.py +++ b/tests/test_uniform_federation.py @@ -326,7 +326,7 @@ def test_timeout_noFed_post(mock_requests, client, two_servers): # Test the async request function -------------------------------------------------------------------- -@patch('federation.FuturesSession.post', side_effect=mocked_async_requests_get) +@patch('federation.requests.post', side_effect=mocked_async_requests_get) def test_valid_asyncRequests_two_servers_get(mock_requests, client, two_servers): with client: FR = get_federation_response("POST", "Federate") @@ -342,7 +342,7 @@ def test_valid_asyncRequests_two_servers_get(mock_requests, client, two_servers) assert Success == [200, 200] -@patch('federation.FuturesSession.post', side_effect=mocked_async_requests_post) +@patch('federation.requests.post', side_effect=mocked_async_requests_post) def test_valid_asyncRequests_two_servers_post(mock_requests, client, two_servers): with client: FR = get_federation_response("POST") @@ -361,7 +361,7 @@ def test_valid_asyncRequests_two_servers_post(mock_requests, client, two_servers # Test Federation with one server -------------------------------------------------------------------- @patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.FuturesSession.post', side_effect=mocked_async_requests_get) +@patch('federation.requests.post', side_effect=mocked_async_requests_get) def test_valid_ServerRequest_one_server_get(mock_requests, mock_session, client, two_servers): with client: FR = get_federation_response("GET", "Federate") @@ -373,7 +373,7 @@ def test_valid_ServerRequest_one_server_get(mock_requests, mock_session, client, @patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.FuturesSession.post', side_effect=mocked_async_requests_get) +@patch('federation.requests.post', side_effect=mocked_async_requests_get) def test_valid_federated_query_one_server_get(mock_requests, mock_session, client, two_servers): with client: with APP.app.test_request_context( @@ -394,7 +394,7 @@ def test_valid_federated_query_one_server_get(mock_requests, mock_session, clien @patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.FuturesSession.post', side_effect=mocked_async_requests_post) +@patch('federation.requests.post', side_effect=mocked_async_requests_post) def test_valid_ServerRequest_one_server_post(mock_session, mock_requests, client, two_servers): with client: FR = get_federation_response("POST", "Federate") @@ -407,7 +407,7 @@ def test_valid_ServerRequest_one_server_post(mock_session, mock_requests, client @patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.FuturesSession.post', side_effect=mocked_async_requests_post) +@patch('federation.requests.post', side_effect=mocked_async_requests_post) def test_valid_federated_query_one_server_post(mock_requests, mock_session, client, two_servers): with client: with APP.app.test_request_context( @@ -432,7 +432,7 @@ def test_valid_federated_query_one_server_post(mock_requests, mock_session, clie @patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.FuturesSession.post', side_effect=mocked_async_requests_get) +@patch('federation.requests.post', side_effect=mocked_async_requests_get) def test_valid_ServerRequest_two_server_get(mock_requests, mock_session, client, three_servers): with client: FR = get_federation_response("GET", "Federate") @@ -446,7 +446,7 @@ def test_valid_ServerRequest_two_server_get(mock_requests, mock_session, client, @patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.FuturesSession.post', side_effect=mocked_async_requests_get) +@patch('federation.requests.post', side_effect=mocked_async_requests_get) def test_valid_federated_query_two_server_get(mock_requests, mock_session, client, three_servers): with client: with APP.app.test_request_context( @@ -468,7 +468,7 @@ def test_valid_federated_query_two_server_get(mock_requests, mock_session, clien @patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.FuturesSession.post', side_effect=mocked_async_requests_post) +@patch('federation.requests.post', side_effect=mocked_async_requests_post) def test_valid_ServerRequest_two_server_post(mock_session, mock_requests, client, three_servers): with client: FR = get_federation_response("POST", "Federate") @@ -482,7 +482,7 @@ def test_valid_ServerRequest_two_server_post(mock_session, mock_requests, client @patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.FuturesSession.post', side_effect=mocked_async_requests_post) +@patch('federation.requests.post', side_effect=mocked_async_requests_post) def test_valid_federated_query_two_server_post(mock_requests, mock_session, client, three_servers): with client: with APP.app.test_request_context(