diff --git a/gateway/conf.py b/gateway/conf.py index da414d3..8096e3f 100644 --- a/gateway/conf.py +++ b/gateway/conf.py @@ -21,7 +21,7 @@ class Settings(BaseModel): # Service URLs RESULTS_SERVICE_URL: str = os.getenv("RESULTS_SERVICE_URL", "http://localhost:8000") KONG_ADMIN_SERVICE_URL: str = os.getenv("RESULTS_SERVICE_URL", "http://localhost:8001") - PODORC_SERVICE_URL: str = os.getenv("PODORC_SERVICE_URL", "http://localhost:8002") + PODORC_SERVICE_URL: str = os.getenv("PODORC_SERVICE_URL", "http://localhost:18080") # UI ID and secret API_CLIENT_ID: str = os.getenv("API_CLIENT_ID", "api-client") diff --git a/tests/conftest.py b/tests/conftest.py index 8df5f50..7b1c0f2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,9 +12,6 @@ from tests.pseudo_auth import BearerAuth -# from tests.pseudo_auth import fakeauth - - @pytest.fixture(scope="session") def test_client(): """Test API client.""" diff --git a/tests/test_kong.py b/tests/test_kong.py index aa83476..e349b4b 100644 --- a/tests/test_kong.py +++ b/tests/test_kong.py @@ -2,15 +2,14 @@ from starlette import status from tests.constants import TEST_DS, TEST_PROJECT -from tests.pseudo_auth import fakeauth class TestKong: """Kong EP tests. Dependent on having a running instance of Kong and admin URL defined in ENV.""" - def test_list_data_stores(self, test_client, setup_kong): + def test_list_data_stores(self, test_client, setup_kong, test_token): """Test the list_data_stores method.""" - r = test_client.get("/datastore", auth=fakeauth) + r = test_client.get("/datastore", auth=test_token) assert r.status_code == status.HTTP_200_OK json_data = r.json() @@ -23,9 +22,9 @@ def test_list_data_stores(self, test_client, setup_kong): data_store_names = [ds["name"] for ds in data] assert TEST_DS in data_store_names - def test_list_data_stores_by_project(self, test_client, setup_kong): + def test_list_data_stores_by_project(self, test_client, setup_kong, test_token): """Test the list_data_stores_by_project method.""" - r = test_client.get(f"/datastore/{TEST_PROJECT}", auth=fakeauth) + r = test_client.get(f"/datastore/{TEST_PROJECT}", auth=test_token) assert r.status_code == status.HTTP_200_OK json_data = r.json() @@ -39,7 +38,7 @@ def test_list_data_stores_by_project(self, test_client, setup_kong): assert data_store["name"] == TEST_PROJECT assert data_store["methods"] == ["GET", "POST", "PUT", "DELETE"] - def test_create_delete_data_store(self, test_client, setup_kong): + def test_create_delete_data_store(self, test_client, setup_kong, test_token): """Test the create_data_store and delete_data_store methods.""" test_ds_name = "theWWW" new_ds = { @@ -49,17 +48,17 @@ def test_create_delete_data_store(self, test_client, setup_kong): "host": "earth", "path": "/cloud", } - r = test_client.post("/datastore", auth=fakeauth, json=new_ds) + r = test_client.post("/datastore", auth=test_token, json=new_ds) assert r.status_code == status.HTTP_201_CREATED new_service = r.json() for k, v in new_ds.items(): assert new_service[k] == v - d = test_client.delete(f"/datastore/{test_ds_name}", auth=fakeauth) + d = test_client.delete(f"/datastore/{test_ds_name}", auth=test_token) assert d.status_code == status.HTTP_200_OK - def test_connect_disconnect_project_to_datastore(self, test_client, setup_kong): + def test_connect_disconnect_project_to_datastore(self, test_client, setup_kong, test_token): """Test the connect_project_to_datastore and disconnect_project methods.""" test_project_name = "Manhattan" proj_specs = { @@ -76,7 +75,7 @@ def test_connect_disconnect_project_to_datastore(self, test_client, setup_kong): ], "ds_type": "fhir" } - r = test_client.post("/datastore/project", auth=fakeauth, json=proj_specs) + r = test_client.post("/datastore/project", auth=test_token, json=proj_specs) assert r.status_code == status.HTTP_200_OK link_data = r.json() @@ -85,20 +84,20 @@ def test_connect_disconnect_project_to_datastore(self, test_client, setup_kong): assert all(found_keys) assert link_data["route"]["name"] == test_project_name - d = test_client.put(f"/disconnect/{test_project_name}", auth=fakeauth) + d = test_client.put(f"/disconnect/{test_project_name}", auth=test_token) assert d.status_code == status.HTTP_200_OK removed_routes = d.json()["removed_routes"] assert len(removed_routes) == 1 - def test_connect_delete_analysis_to_project(self, test_client, setup_kong): + def test_connect_delete_analysis_to_project(self, test_client, setup_kong, test_token): """Test the connect_analysis_to_project method.""" test_analysis = "datalore" analysis_request = { "project_id": TEST_PROJECT, "analysis_id": test_analysis, } - r = test_client.post("/project/analysis", auth=fakeauth, json=analysis_request) + r = test_client.post("/project/analysis", auth=test_token, json=analysis_request) assert r.status_code == status.HTTP_202_ACCEPTED link_data = r.json() @@ -109,5 +108,5 @@ def test_connect_delete_analysis_to_project(self, test_client, setup_kong): assert link_data["consumer"]["username"] == test_analysis assert link_data["consumer"]["tags"] == [TEST_PROJECT] - d = test_client.delete(f"/analysis/{test_analysis}", auth=fakeauth) + d = test_client.delete(f"/analysis/{test_analysis}", auth=test_token) assert d.status_code == status.HTTP_200_OK diff --git a/tests/test_podorc.py b/tests/test_podorc.py index ce2be25..d96a2b7 100644 --- a/tests/test_podorc.py +++ b/tests/test_podorc.py @@ -4,15 +4,14 @@ from starlette import status from tests.constants import TEST_ANALYSIS -from tests.pseudo_auth import fakeauth class TestPodOrc: """Pod orchestration tests.""" - def test_get_po_status(self, test_client, setup_po): + def test_get_po_status(self, test_client, setup_po, test_token): """Test the get_analysis_status method.""" - r = test_client.get(f"/po/{TEST_ANALYSIS}/status", auth=fakeauth) + r = test_client.get(f"/po/{TEST_ANALYSIS}/status", auth=test_token) assert r.status_code == status.HTTP_200_OK resp = r.json() @@ -22,9 +21,9 @@ def test_get_po_status(self, test_client, setup_po): assert pod_name.startswith(TEST_ANALYSIS) assert pod_status == "running" - def test_get_po_logs(self, test_client, setup_po): + def test_get_po_logs(self, test_client, setup_po, test_token): """Test the get_analysis_logs method.""" - r = test_client.get(f"/po/{TEST_ANALYSIS}/logs", auth=fakeauth) + r = test_client.get(f"/po/{TEST_ANALYSIS}/logs", auth=test_token) assert r.status_code == status.HTTP_200_OK resp = r.json() @@ -34,9 +33,9 @@ def test_get_po_logs(self, test_client, setup_po): assert pod_name.startswith(TEST_ANALYSIS) assert isinstance(pod_log, list) - def test_get_po_pods(self, test_client, setup_po): + def test_get_po_pods(self, test_client, setup_po, test_token): """Test the get_analysis_pods method.""" - r = test_client.get(f"/po/{TEST_ANALYSIS}/pods", auth=fakeauth) + r = test_client.get(f"/po/{TEST_ANALYSIS}/pods", auth=test_token) assert r.status_code == status.HTTP_200_OK resp = r.json() @@ -45,7 +44,7 @@ def test_get_po_pods(self, test_client, setup_po): assert isinstance(pods, list) assert len(pods) == 1 - def test_create_stop_delete_pod(self, test_client): + def test_create_stop_delete_pod(self, test_client, test_token): """Test the create_analysis, stop_analysis, and delete_analysis methods.""" analysis_test = "podorcanalysistest" # Must be all lower case for podorc unittests test_deploy = { @@ -54,7 +53,7 @@ def test_create_stop_delete_pod(self, test_client): } # Create pod - create_r = test_client.post("/po", auth=fakeauth, json=test_deploy) + create_r = test_client.post("/po", auth=test_token, json=test_deploy) assert create_r.status_code == status.HTTP_200_OK pod_creation_status = create_r.json() @@ -63,7 +62,7 @@ def test_create_stop_delete_pod(self, test_client): time.sleep(2) # Stop pod - stop_r = test_client.put(f"/po/{analysis_test}/stop", auth=fakeauth) + stop_r = test_client.put(f"/po/{analysis_test}/stop", auth=test_token) assert stop_r.status_code == status.HTTP_200_OK pod_stop_resp = stop_r.json() @@ -76,7 +75,7 @@ def test_create_stop_delete_pod(self, test_client): time.sleep(2) # Delete pod - delete_r = test_client.delete(f"/po/{analysis_test}/delete", auth=fakeauth) + delete_r = test_client.delete(f"/po/{analysis_test}/delete", auth=test_token) assert delete_r.status_code == status.HTTP_200_OK pod_delete_resp = delete_r.json()