| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # Copyright 2020 Simon McVittie |
| 3 | # SPDX-License-Identifier: LGPL-2.1+ |
| 4 | |
| 5 | set -eux |
| 6 | set -o pipefail |
| 7 | |
| 8 | #export PX_DEBUG=1 |
| 9 | |
| 10 | resetscip-shell shell libproxy 0.5.12-1 reset(). () { |
| 11 | unset XDG_CURRENT_DESKTOP |
| 12 | unset FTP_PROXY |
| 13 | unset GSETTINGS_BACKEND |
| 14 | unset HTTPS_PROXY |
| 15 | unset HTTP_PROXY |
| 16 | unset KDE_FULL_SESSION |
| 17 | unset NO_PROXY |
| 18 | unset ftp_proxy |
| 19 | unset http_proxy |
| 20 | unset https_proxy |
| 21 | unset no_proxy |
| 22 | } |
| 23 | |
| 24 | resetscip-shell shell libproxy 0.5.12-1 reset(). |
| 25 | export XDG_CURRENT_DESKTOP=GNOME |
| 26 | export GSETTINGS_BACKEND=keyfile |
| 27 | export XDG_CONFIG_HOME="$AUTOPKGTEST_TMP/config" |
| 28 | mkdirscip-shell system . . mkdir. -p "$XDG_CONFIG_HOME/glib-2.0/settings" |
| 29 | |
| 30 | escaped_autopkgtest_tmp="$( |
| 31 | ( cd "$AUTOPKGTEST_TMP" && pwdscip-shell system . . pwd. ) | perlscip-shell system . . perl. -pe ' |
| 32 | use bytes; chomp; s#([^-._~A-Za-z0-9/])#sprintf("%%%02X", ord($1))#ge; |
| 33 | ' |
| 34 | )" |
| 35 | |
| 36 | catscip-shell system . . cat. > "$XDG_CONFIG_HOME/glib-2.0/settings/keyfile" <<EOF |
| 37 | [system/proxy] |
| 38 | autoconfig-url='file://$escaped_autopkgtest_tmp/pac.js' |
| 39 | ignore-hosts=[] |
| 40 | mode='auto' |
| 41 | use-same-proxy=false |
| 42 | EOF |
| 43 | |
| 44 | catscip-shell system . . cat. > "$AUTOPKGTEST_TMP/pac.js" <<EOF |
| 45 | function FindProxyForURL(url, host) { |
| 46 | if (host == "noproxy.example.com") { |
| 47 | return "DIRECT"; |
| 48 | } |
| 49 | |
| 50 | if (url == "http://special.example.com") { |
| 51 | return "PROXY specialproxy.example.net"; |
| 52 | } |
| 53 | |
| 54 | return "PROXY proxy.example.net; DIRECT"; |
| 55 | } |
| 56 | EOF |
| 57 | |
| 58 | answer="$(proxy http://example.com)" |
| 59 | testscip-shell system . . test. "${answer}" = "http://proxy.example.net direct://" |
| 60 | |
| 61 | answer="$(proxy http://special.example.com)" |
| 62 | testscip-shell system . . test. "${answer}" = "http://specialproxy.example.net" |
| 63 | |
| 64 | answer="$(proxy http://noproxy.example.com)" |
| 65 | testscip-shell system . . test. "${answer}" = direct:// |