diff --git a/base-notebook/docker_healthcheck.py b/base-notebook/docker_healthcheck.py index 7c35a6b115..41bbc78568 100755 --- a/base-notebook/docker_healthcheck.py +++ b/base-notebook/docker_healthcheck.py @@ -16,6 +16,11 @@ url = json.loads(json_file.read_bytes())["url"] url = url + "api" -r = requests.get(url, verify=False) # request without SSL verification +proxies = { + "http": "", + "https": "", +} + +r = requests.get(url, proxies=proxies, verify=False) # request without SSL verification r.raise_for_status() print(r.content) diff --git a/tests/base-notebook/test_healthcheck.py b/tests/base-notebook/test_healthcheck.py index 2b15faf605..73de100303 100644 --- a/tests/base-notebook/test_healthcheck.py +++ b/tests/base-notebook/test_healthcheck.py @@ -69,6 +69,53 @@ def test_health( assert get_health(running_container) == "healthy" +@pytest.mark.parametrize( + "env,cmd,user", + [ + ( + ["HTTPS_PROXY=host.docker.internal", "HTTP_PROXY=host.docker.internal"], + None, + None, + ), + ( + [ + "NB_USER=testuser", + "CHOWN_HOME=1", + "JUPYTER_PORT=8123", + "HTTPS_PROXY=host.docker.internal", + "HTTP_PROXY=host.docker.internal", + ], + ["start-notebook.sh", "--ServerApp.base_url=/test"], + "root", + ), + ], +) +def test_health_proxy( + container: TrackedContainer, + env: Optional[list[str]], + cmd: Optional[list[str]], + user: Optional[str], +) -> None: + running_container = container.run_detached( + tty=True, + environment=env, + command=cmd, + user=user, + ) + + # sleeping some time to let the server start + time_spent = 0.0 + wait_time = 0.1 + time_limit = 15 + while time_spent < time_limit: + time.sleep(wait_time) + time_spent += wait_time + if get_health(running_container) == "healthy": + return + + assert get_health(running_container) == "healthy" + + @pytest.mark.parametrize( "env,cmd,user", [