Skip to content

Commit

Permalink
♻️ Tests should use the url that directly accesses servers
Browse files Browse the repository at this point in the history
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
  • Loading branch information
znatty22 committed Jul 29, 2024
1 parent 8fc44ef commit 97fd101
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
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
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 97fd101

Please sign in to comment.