summaryrefslogtreecommitdiff
path: root/test/integration/test-ubuntu-bug-2150631-authconf-unreadable-source
blob: 0a22e8f83f960b13e0dea18823106687f1745a88 (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
#!/bin/sh
set -e

TESTDIR="$(readlink -f "$(dirname "$0")")"
. "$TESTDIR/framework"

setupenvironment
configarchitecture "amd64"

if [ "$(id -u)" = '0' ]; then
	msgskip "Tests for unreadable auth.conf files do not work as root"
	exit 0
fi

buildsimplenativepackage "foo" "all" "1"
setupaptarchive --no-update

changetohttpswebserver --authorization="$(printf '%s' 'star@irc:hunter2' | base64 )"
rewritesourceslist "https://localhost:${APTHTTPSPORT}/"

AUTHCONF="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/auth.conf.d/private.conf"
mkdir -p "$(dirname "$AUTHCONF")"
printf '%s\n' \
	"machine https://localhost" \
	"login star@irc" \
	"password hunter2" > "$AUTHCONF"
chmod 600 "$AUTHCONF"

testsuccess aptget update

chmod 000 "$AUTHCONF"
testfailure aptget source -d foo

OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output"
testsuccess grep -F "Authentication credentials may be configured in ${AUTHCONF}" "$OUTPUT"
testsuccess grep -F "not readable by the current user. Try running this command as root." "$OUTPUT"
testsuccess grep -E "401[[:space:]]+Unauthorized" "$OUTPUT"