Skip to content

Commit

Permalink
Minor tweaks to aid in local integration testing
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvanrun committed Jan 14, 2025
1 parent b606be8 commit 44c884e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions gcapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def __init__(
self._auth_header = _generate_auth_header(token=token)

self.base_url = URL(base_url)
if self.base_url.scheme.lower() != "https":
if verify and self.base_url.scheme.lower() != "https":
raise RuntimeError("Base URL must be https")

self._api_meta = ApiDefinitions()
Expand All @@ -439,7 +439,10 @@ def __getattr__(self, item):
def validate_url(self, url):
url = URL(url)

if not url.scheme == "https" or url.netloc != self.base_url.netloc:
if (
url.scheme.lower() != self.base_url.scheme.lower()
or url.netloc != self.base_url.netloc
):
raise RuntimeError(f"Invalid target URL: {url}")

def __call__(
Expand Down
6 changes: 5 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ def anyio_backend():

@pytest.fixture(scope="session")
def local_grand_challenge() -> Generator[str, None, None]:
local_api_url = "https://gc.localhost/api/v1/"
local_api_url = os.environ.get(
"LOCAL_API_URL",
"https://gc.localhost/api/v1/",
)

try:
r = httpx.get(
local_api_url,
verify=False,
headers={"Authorization": f"Bearer {ADMIN_TOKEN}"},
)

r.raise_for_status()
local_gc_running = True
except httpx.HTTPError:
Expand Down

0 comments on commit 44c884e

Please sign in to comment.