summaryrefslogtreecommitdiff
path: root/tests/setup_proxy_test
blob: e825796ea6fd3bbd114109c9e473a2442aa0f3c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env atf-sh

. $(atf_get_srcdir)/test_env.sh
init_tests \
	setup_proxy_usage \
	setup_proxy_url \
	setup_proxy_none \
	setup_proxy_interactive_none

setup_proxy_usage_body() {
	test_usage setup-proxy
}

setup_proxy_url_body() {
	init_env
	atf_check -s exit:0 \
		-o match:'^apk add.*wget' \
		-e empty \
		setup-proxy https://example.com
	grep http_proxy etc/profile.d/proxy.sh || atf_fail "http_proxy not set in etc/profile.d/proxy.sh"
}

setup_proxy_none_body() {
	init_env

	mkdir -p etc/profile.d
	touch etc/profile.d/proxy.sh

	atf_check -s exit:0 \
		-o empty \
		-e empty \
		setup-proxy none

	if test -e etc/profile.d/proxy.sh; then
		atf_fail "etc/profile.d/proxy.sh was not removed"
	fi
}

setup_proxy_interactive_none_body() {
	init_env

	mkdir -p etc/profile.d
	touch etc/profile.d/proxy.sh

	echo none | atf_check -s exit:0 \
		 -o match:"HTTP/FTP proxy URL" \
		 -e empty \
		 setup-proxy

	if test -e etc/profile.d/proxy.sh; then
		 atf_fail "etc/profile.d/proxy.sh was not removed"
	fi
}