diff --git a/src/antares/craft/api_conf/api_conf.py b/src/antares/craft/api_conf/api_conf.py index ad621cab..bb3fa3fc 100644 --- a/src/antares/craft/api_conf/api_conf.py +++ b/src/antares/craft/api_conf/api_conf.py @@ -53,9 +53,12 @@ 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() @@ -63,4 +66,6 @@ def set_up_api_conf(self) -> requests.Session: 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 diff --git a/tests/integration/antares_web_desktop.py b/tests/integration/antares_web_desktop.py index b77af98c..32cc81b9 100644 --- a/tests/integration/antares_web_desktop.py +++ b/tests/integration/antares_web_desktop.py @@ -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 @@ -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: