Skip to content

Commit

Permalink
Merge pull request #197 from kids-first/fhir-direct-url
Browse files Browse the repository at this point in the history
🛠️ Use FHIR Direct URL for tests
  • Loading branch information
znatty22 authored Jul 30, 2024
2 parents eacdf07 + 97fd101 commit fed7cec
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,8 @@ data/

# JS files
node_modules

# Vim files
*.swp
*.swo
*.swn
1 change: 1 addition & 0 deletions env.sample
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Empty file added src/__init__.py
Empty file.
1 change: 1 addition & 0 deletions src/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions tests/python/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions tests/python/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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)


Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand Down
Empty file.

0 comments on commit fed7cec

Please sign in to comment.