Skip to content

Commit

Permalink
disable proxy on local versions
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Feb 10, 2025
1 parent 05bacae commit a5912b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/antares/craft/api_conf/api_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,19 @@ def get_token(self) -> str:
return self._token

def checks_token(self) -> None:
if self._api_host not in ["localhost", "127.0.0.1"] and self._token is None:
if not self.is_launched_locally() and self._token is None:
raise MissingTokenError()

def is_launched_locally(self) -> bool:
return self._api_host.startswith(("localhost", "http://127.0.0.1"))

def set_up_api_conf(self) -> requests.Session:
self.checks_token()
session = requests.Session()
session.verify = self._verify
if self._token:
token_bearer = f"Bearer {self._token}"
session.headers.update({"Authorization": token_bearer})
if self.is_launched_locally():
session.trust_env = False # disable proxy
return session
5 changes: 4 additions & 1 deletion tests/integration/antares_web_desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def __init__(self):
def _is_server_ready(self):
healthcheck_url = f"{self.url}/api/health"
try:
res = requests.get(healthcheck_url)
session = requests.Session()
session.trust_env = False
res = session.get(healthcheck_url)
return res.status_code == 200
except requests.RequestException:
return False
Expand All @@ -64,6 +66,7 @@ def kill(self):
It also kills the AntaresWebDesktop instance.
"""
session = requests.Session()
session.trust_env = False
res = session.get(self.url + "/api/v1/studies")
studies = res.json()
for study in studies:
Expand Down

0 comments on commit a5912b2

Please sign in to comment.