From 37bd52a836887443aa9860c392cabf3e04fb04ba Mon Sep 17 00:00:00 2001 From: Natasha Singh Date: Mon, 29 Jul 2024 15:15:17 -0400 Subject: [PATCH 1/3] :see_no_evil: Ignore vim files --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index f2ba359..a885842 100644 --- a/.gitignore +++ b/.gitignore @@ -147,3 +147,8 @@ data/ # JS files node_modules + +# Vim files +*.swp +*.swo +*.swn From 8fc44ef712ede84fc87a4d364bc69ca0ce0eb3be Mon Sep 17 00:00:00 2001 From: Natasha Singh Date: Mon, 29 Jul 2024 15:46:39 -0400 Subject: [PATCH 2/3] :recycle: Add FHIR server direct URL for tests to use --- src/__init__.py | 0 src/config/__init__.py | 1 + 2 files changed, 1 insertion(+) create mode 100644 src/__init__.py diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/config/__init__.py b/src/config/__init__.py index 4e3101e..702fb06 100644 --- a/src/config/__init__.py +++ b/src/config/__init__.py @@ -12,6 +12,7 @@ BASE_URL = os.environ.get("FHIR_ENDPOINT") FHIR_URL = BASE_URL +FHIR_DIRECT_URL = os.environ.get("FHIR_DIRECT_ENDPOINT") FHIR_APP_ADMIN = os.environ.get("FHIR_APP_ADMIN") FHIR_APP_ADMIN_PW = os.environ.get("FHIR_APP_ADMIN_PW") FHIR_TEST_USER_PW = os.environ.get("FHIR_TEST_USER_PW") From 97fd101e23970e4d29418a92432d097c09a94b45 Mon Sep 17 00:00:00 2001 From: Natasha Singh Date: Mon, 29 Jul 2024 15:46:45 -0400 Subject: [PATCH 3/3] :recycle: Tests should use the url that directly accesses servers The short urls are meant for browser based access and should not be used for the integration tests. Set a new env variable that the tests will read and use --- env.sample | 1 + tests/python/conftest.py | 6 +++--- tests/python/test_auth.py | 12 ++++++------ tests/python/test_search_parameters.py | 0 4 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 tests/python/test_search_parameters.py diff --git a/env.sample b/env.sample index ad129fb..3515c57 100644 --- a/env.sample +++ b/env.sample @@ -1,6 +1,7 @@ # --- Smile CDR FHIR Server Configuration --- # Needed in properties, setup_dev_env.sh, bin/health-check.sh FHIR_ENDPOINT=http://localhost:8000 +FHIR_DIRECT_ENDPOINT=http://localhost:8000 # Needed in bin/seed_users.py USER_MGMNT_ENDPOINT=http://localhost:9000/user-management # Needed in properties file diff --git a/tests/python/conftest.py b/tests/python/conftest.py index 250e741..1c425dc 100644 --- a/tests/python/conftest.py +++ b/tests/python/conftest.py @@ -4,7 +4,7 @@ from requests.auth import HTTPBasicAuth from src.config import ( - FHIR_URL, + FHIR_DIRECT_URL, USER_MGMNT_ENDPOINT, FHIR_APP_ADMIN, FHIR_APP_ADMIN_PW, @@ -83,7 +83,7 @@ def _upsert_fhir_resources(resources): for resource in resources: id_ = resource["id"] resource_type = resource["resourceType"] - url = f"{FHIR_URL}/{resource_type}/{id_}" + url = f"{FHIR_DIRECT_URL}/{resource_type}/{id_}" kwargs.update({"json": resource}) resp = send_request("put", url, **kwargs) @@ -100,7 +100,7 @@ def _upsert_fhir_resources(resources): for resource in upserted: id_ = resource["id"] resource_type = resource["resourceType"] - url = f"{FHIR_URL}/{resource_type}/{id_}" + url = f"{FHIR_DIRECT_URL}/{resource_type}/{id_}" kwargs.update({"json": resource}) send_request("delete", url, **kwargs) diff --git a/tests/python/test_auth.py b/tests/python/test_auth.py index 7fed8a5..7e750ab 100644 --- a/tests/python/test_auth.py +++ b/tests/python/test_auth.py @@ -4,7 +4,7 @@ from requests.auth import HTTPBasicAuth from src.config import ( - FHIR_URL, + FHIR_DIRECT_URL, KEYCLOAK_READ_CLIENT_ID, KEYCLOAK_READ_CLIENT_SECRET, ) @@ -19,7 +19,7 @@ def test_anonymous_valid_actions(action, endpoint): """ Test that anonymous user can GET /metadata and /swagger-ui """ - url = f"{FHIR_URL}/{endpoint}" + url = f"{FHIR_DIRECT_URL}/{endpoint}" resp = send_request(action, url) @@ -40,7 +40,7 @@ def test_anonymous_invalid_actions(action, endpoint): } kwargs = {"json": patient} - url = f"{FHIR_URL}/{endpoint}" + url = f"{FHIR_DIRECT_URL}/{endpoint}" with pytest.raises(requests.exceptions.HTTPError) as e: resp = send_request(action, url, **kwargs) @@ -54,7 +54,7 @@ def test_crud_with_basic_auth(fhir_superuser): """ username = fhir_superuser["username"] password = fhir_superuser["password"] - url = f"{FHIR_URL}/Patient" + url = f"{FHIR_DIRECT_URL}/Patient" kwargs = {"auth": HTTPBasicAuth(username, password)} # Post @@ -95,7 +95,7 @@ def test_crud_with_oidc_auth(): "Authorization": f"Bearer {access_token}" } } - url = f"{FHIR_URL}/Patient" + url = f"{FHIR_DIRECT_URL}/Patient" # Post patient = { @@ -139,7 +139,7 @@ def test_read_only_oidc_client(patients): "Authorization": f"Bearer {access_token}" } } - url = f"{FHIR_URL}/Patient" + url = f"{FHIR_DIRECT_URL}/Patient" # Post - Fail patient = { diff --git a/tests/python/test_search_parameters.py b/tests/python/test_search_parameters.py new file mode 100644 index 0000000..e69de29