Skip to content

Commit

Permalink
refactor(kong): add kong prefix to kong EPs
Browse files Browse the repository at this point in the history
  • Loading branch information
brucetony committed Apr 5, 2024
1 parent 8becce7 commit 30381dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions gateway/routers/kong.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
dependencies=[Security(verify_idp_token), Security(idp_oauth2_scheme_pass), Security(httpbearer)],
tags=["Kong"],
responses={404: {"description": "Not found"}},
prefix="/kong"
)

logger = logging.getLogger(__name__)
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ def setup_kong(test_client, test_token):
"protocols": ["http"],
}

test_client.post("/datastore", auth=test_token, json=test_datastore)
test_client.post("/datastore/project", auth=test_token, json=test_project_link)
test_client.post("/kong/datastore", auth=test_token, json=test_datastore)
test_client.post("/kong/datastore/project", auth=test_token, json=test_project_link)

yield

test_client.put(f"/disconnect/{TEST_PROJECT}", auth=test_token)
test_client.delete(f"/datastore/{TEST_DS}", auth=test_token)
test_client.put(f"/kong/disconnect/{TEST_PROJECT}", auth=test_token)
test_client.delete(f"/kong/datastore/{TEST_DS}", auth=test_token)


@pytest.fixture(scope="module")
Expand Down
16 changes: 8 additions & 8 deletions tests/test_kong.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TestKong:

def test_list_data_stores(self, test_client, setup_kong, test_token):
"""Test the list_data_stores method."""
r = test_client.get("/datastore", auth=test_token)
r = test_client.get("/kong/datastore", auth=test_token)
assert r.status_code == status.HTTP_200_OK

json_data = r.json()
Expand All @@ -24,7 +24,7 @@ def test_list_data_stores(self, test_client, setup_kong, test_token):

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=test_token)
r = test_client.get(f"/kong/datastore/{TEST_PROJECT}", auth=test_token)
assert r.status_code == status.HTTP_200_OK

json_data = r.json()
Expand All @@ -48,14 +48,14 @@ def test_create_delete_data_store(self, test_client, setup_kong, test_token):
"host": "earth",
"path": "/cloud",
}
r = test_client.post("/datastore", auth=test_token, json=new_ds)
r = test_client.post("/kong/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=test_token)
d = test_client.delete(f"/kong/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, test_token):
Expand All @@ -75,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=test_token, json=proj_specs)
r = test_client.post("/kong/datastore/project", auth=test_token, json=proj_specs)
assert r.status_code == status.HTTP_200_OK
link_data = r.json()

Expand All @@ -84,7 +84,7 @@ 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=test_token)
d = test_client.put(f"/kong/disconnect/{test_project_name}", auth=test_token)
assert d.status_code == status.HTTP_200_OK

removed_routes = d.json()["removed_routes"]
Expand All @@ -97,7 +97,7 @@ def test_connect_delete_analysis_to_project(self, test_client, setup_kong, test_
"project_id": TEST_PROJECT,
"analysis_id": test_analysis,
}
r = test_client.post("/project/analysis", auth=test_token, json=analysis_request)
r = test_client.post("/kong/project/analysis", auth=test_token, json=analysis_request)
assert r.status_code == status.HTTP_202_ACCEPTED

link_data = r.json()
Expand All @@ -108,5 +108,5 @@ def test_connect_delete_analysis_to_project(self, test_client, setup_kong, test_
assert link_data["consumer"]["username"] == test_analysis
assert link_data["consumer"]["tags"] == [TEST_PROJECT]

d = test_client.delete(f"/analysis/{test_analysis}", auth=test_token)
d = test_client.delete(f"/kong/analysis/{test_analysis}", auth=test_token)
assert d.status_code == status.HTTP_200_OK

0 comments on commit 30381dc

Please sign in to comment.