#!/bin/bash

set -eux
set -o pipefail

unset DESKTOP_SESSION
unset FTP_PROXY
unset GNOME_DESKTOP_SESSION_ID
unset HTTPS_PROXY
unset HTTP_PROXY
unset KDE_FULL_SESSION
unset NO_PROXY
unset ftp_proxy
unset http_proxy
unset https_proxy
unset no_proxy

# TODO: This test fails: the script outputs b'direct://', etc. due to
# #959030

for python in $(py3versions -s); do
    answer="$(http_proxy=http://proxy.example.net https_proxy=http://sslproxy.example.net "$python" ./debian/tests/resolve-proxy.py http://example.com)"
    test "$answer" = http://proxy.example.net
    answer="$(http_proxy=http://proxy.example.net https_proxy=http://sslproxy.example.net "$python" ./debian/tests/resolve-proxy.py https://example.com)"
    test "$answer" = http://sslproxy.example.net
    answer="$(http_proxy=http://proxy.example.net no_proxy=example.com "$python" ./debian/tests/resolve-proxy.py https://example.com)"
    test "$answer" = direct://
done
