]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-apt-get-changelog
tests: don't use hardcoded port for http and https
[apt.git] / test / integration / test-apt-get-changelog
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4TESTDIR=$(readlink -f $(dirname $0))
5. $TESTDIR/framework
6
7setupenvironment
8configarchitecture 'native'
9
10buildsimplenativepackage 'foo' 'all' '1.0' 'stable'
11buildsimplenativepackage 'libbar' 'all' '1.0' 'stable'
12
13getlabelfromsuite() { echo 'Testcases'; }
14getoriginfromsuite() { echo 'Debian'; }
15
16setupaptarchive --no-update
17changetowebserver
18testsuccess aptget update
19
20testsuccessequal "'http://metadata.ftp-master.debian.org/changelogs/main/f/foo/foo_1.0_changelog' foo.changelog
21'http://metadata.ftp-master.debian.org/changelogs/main/libb/libbar/libbar_1.0_changelog' libbar.changelog" aptget changelog foo libbar --print-uris
22
23releasechanger() {
24 # modifying the Release files in lists… bad stuff. Good that this is only a test…
25 sed -i "s#^${1}: .*#${1}: ${2}#" $(find rootdir/var/lib/apt/lists -name '*Release')
26 rm -f rootdir/var/cache/apt/*.bin
27}
28releasechanger 'Origin' 'Ubuntu'
29testsuccessequal "'http://changelogs.ubuntu.com/changelogs/pool/main/f/foo/foo_1.0/changelog' foo.changelog
30'http://changelogs.ubuntu.com/changelogs/pool/main/libb/libbar/libbar_1.0/changelog' libbar.changelog" aptget changelog foo libbar --print-uris
31
32releasechanger 'Label' 'Debian'
33testsuccessequal "'http://changelogs.ubuntu.com/changelogs/pool/main/f/foo/foo_1.0/changelog' foo.changelog
34'http://changelogs.ubuntu.com/changelogs/pool/main/libb/libbar/libbar_1.0/changelog' libbar.changelog" aptget changelog foo libbar --print-uris
35
36testsuccessequal "'http://localhost:${APTHTTPPORT}/main/f/foo/foo_1.0.changelog' foo.changelog
37'http://localhost:${APTHTTPPORT}/main/libb/libbar/libbar_1.0.changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Label::Debian="http://localhost:${APTHTTPPORT}/CHANGEPATH.changelog"
38
39sed -i '/^Origin: / a\
40Changelogs: http://example.org/CHANGEPATH-changelog' $(find rootdir/var/lib/apt/lists -name '*Release')
41rm -f rootdir/var/cache/apt/*.bin
42
43testsuccessequal "'http://example.org/main/f/foo/foo_1.0-changelog' foo.changelog
44'http://example.org/main/libb/libbar/libbar_1.0-changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Label::Debian="http://localhost:${APTHTTPPORT}/CHANGEPATH.changelog"
45
46testsuccessequal "'http://localhost:${APTHTTPPORT}/main/f/foo/foo_1.0.changelog' foo.changelog
47'http://localhost:${APTHTTPPORT}/main/libb/libbar/libbar_1.0.changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Override::Label::Debian="http://localhost:${APTHTTPPORT}/CHANGEPATH.changelog"
48
49releasechanger 'Changelogs' 'no'
50if [ "$(id -u)" = '0' ]; then
51 testfailuremsg "W: Can't drop privileges for downloading as file 'foo.changelog' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
52E: Failed to fetch changelog:/foo.changelog Changelog unavailable for foo=1.0" aptget changelog foo -d
53else
54 testfailuremsg 'E: Failed to fetch changelog:/foo.changelog Changelog unavailable for foo=1.0' aptget changelog foo -d
55fi
56
57sed -i '/^Changelogs: / d' $(find rootdir/var/lib/apt/lists -name '*Release')
58releasechanger 'Label' 'Testcases'
59
60echo "Acquire::Changelogs::URI::Label::Testcases \"http://localhost:${APTHTTPPORT}/CHANGEPATH/change.txt\";" > rootdir/etc/apt/apt.conf.d/changelog.conf
61testsuccessequal "'http://localhost:${APTHTTPPORT}/main/f/foo/foo_1.0/change.txt' foo.changelog
62'http://localhost:${APTHTTPPORT}/main/libb/libbar/libbar_1.0/change.txt' libbar.changelog" aptget changelog foo libbar --print-uris
63
64echo "Acquire::Changelogs::URI::Label::Testcases \"http://localhost:${APTHTTPPORT}/pool/CHANGEPATH/changelog\";" > rootdir/etc/apt/apt.conf.d/changelog.conf
65testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog" aptget changelog foo --print-uris
66
67
68testsuccess aptget changelog foo -qq
69testfileequal 'rootdir/tmp/testsuccess.output' "$(cat aptarchive/pool/main/f/foo/foo_1.0/changelog)"
70
71testsuccess aptget changelog foo libbar -qq
72testfileequal 'rootdir/tmp/testsuccess.output' "$(cat aptarchive/pool/main/f/foo/foo_1.0/changelog)
73$(cat aptarchive/pool/main/libb/libbar/libbar_1.0/changelog)"
74
75cd downloaded
76
77testsuccess aptget changelog foo -d
78testfilestats 'foo.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
79testfileequal 'foo.changelog' "$(cat ../aptarchive/pool/main/f/foo/foo_1.0/changelog)"
80rm -f foo.changelog
81
82testsuccess aptget changelog libbar foo -d
83testfilestats 'libbar.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
84testfilestats 'foo.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
85testfileequal 'libbar.changelog' "$(cat ../aptarchive/pool/main/libb/libbar/libbar_1.0/changelog)"
86testfileequal 'foo.changelog' "$(cat ../aptarchive/pool/main/f/foo/foo_1.0/changelog)"
87rm -f libbar.changelog foo.changelog
88
89# as such bogus, but can happen with multiple binaries from the same source
90testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog
91'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog" aptget changelog foo foo --print-uris
92testsuccess aptget changelog foo foo -qq
93testfileequal '../rootdir/tmp/testsuccess.output' "$(cat ../aptarchive/pool/main/f/foo/foo_1.0/changelog)
94$(cat ../aptarchive/pool/main/f/foo/foo_1.0/changelog)"
95testsuccess aptget changelog foo foo -d
96testfilestats 'foo.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
97testfileequal 'foo.changelog' "$(cat ../aptarchive/pool/main/f/foo/foo_1.0/changelog)"
98rm -f foo.changelog
99
100# no CHANGEPATH in the URI
101testequal 'E: Failed to fetch changelog:/foo.changelog Changelog unavailable for foo=1.0
102' aptget changelog foo -qq -d -o Acquire::Changelogs::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/change.txt"
103testfailure test -e foo.changelog
104
105testequal "E: Failed to fetch http://localhost:${APTHTTPPORT}/does/not/exist/main/f/foo/foo_1.0/change.txt Changelog unavailable for foo=1.0 (404 Not Found)
106" aptget changelog foo -qq -d -o Acquire::Changelogs::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/does/not/exist/CHANGEPATH/change.txt"
107testfailure test -e foo.changelog