]> git.saurik.com Git - apt.git/blame - test/integration/test-releasefile-date-older
properly format multiline error messages
[apt.git] / test / integration / test-releasefile-date-older
CommitLineData
6bf93605
DK
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
6bf93605
DK
6setupenvironment
7configarchitecture 'i386'
8
9insertpackage 'wheezy' 'apt' 'all' '0.8.15'
10
11setupaptarchive --no-update
12
13# we don't complain as the server could have just sent a 'Hit' here and this
14# 'downgrade attack' is usually performed by out-of-sync mirrors. Valid-Until
15# catches the 'real' downgrade attacks (expect that it finds stale mirrors).
16# Scaring users with an error here serves hence no point.
17
18msgmsg 'InRelease file is silently rejected if' 'new Date is before old Date'
19rm -rf rootdir/var/lib/apt/lists
20generatereleasefiles 'now' 'now + 7 days'
21signreleasefiles
22testsuccess aptget update
23listcurrentlistsdirectory > listsdir.lst
24redatereleasefiles 'now - 2 days'
25testsuccess aptget update
26testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
27
28msgmsg 'Release.gpg file is silently rejected if' 'new Date is before old Date'
29rm -rf rootdir/var/lib/apt/lists
30generatereleasefiles 'now' 'now + 7 days'
31signreleasefiles
32find aptarchive -name 'InRelease' -delete
33testsuccess aptget update
34listcurrentlistsdirectory > listsdir.lst
35redatereleasefiles 'now - 2 days'
36find aptarchive -name 'InRelease' -delete
37testsuccess aptget update
38testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
39
40msgmsg 'Crisscross InRelease/Release.gpg file is silently rejected if' 'new Date is before old Date'
41rm -rf rootdir/var/lib/apt/lists
42generatereleasefiles 'now' 'now + 7 days'
43signreleasefiles
44find aptarchive -name 'Release.gpg' -delete
45testsuccess aptget update
46listcurrentlistsdirectory > listsdir.lst
47redatereleasefiles 'now - 2 days'
48find aptarchive -name 'InRelease' -delete
49testsuccess aptget update
50testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
51
52msgmsg 'Crisscross Release.gpg/InRelease file is silently rejected if' 'new Date is before old Date'
53rm -rf rootdir/var/lib/apt/lists
54generatereleasefiles 'now' 'now + 7 days'
55signreleasefiles
56find aptarchive -name 'InRelease' -delete
57testsuccess aptget update
58listcurrentlistsdirectory > listsdir.lst
59redatereleasefiles 'now - 2 days'
60find aptarchive -name 'Release.gpg' -delete
61testsuccess aptget update
62testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
6fc2e030
DK
63
64msgmsg 'Release file has' 'no Date and no Valid-Until field'
65rm -rf rootdir/var/lib/apt/lists
66generatereleasefiles 'now'
67sed -i '/^Date: / d' $(find ./aptarchive -name 'Release')
68signreleasefiles
69testwarning aptget update
70listcurrentlistsdirectory > listsdir.lst
71# have no effect as Date is unknown
72testwarning aptget update -o Acquire::Min-ValidTime=$((3600*24*30))
73testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
74testwarning aptget update -o Acquire::Max-ValidTime=1
75testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
76sed -i '/^Codename: / a\
77Another-Field: yes' $(find aptarchive/ -name 'Release')
78touch -d 'now + 1 day' $(find aptarchive/ -name 'Release')
79signreleasefiles "${2:-Joe Sixpack}"
80testwarning aptget update
81testsuccess cmp $(find aptarchive/ -name 'InRelease') $(find rootdir/var/lib/apt/ -name '*_InRelease')
82
83msgmsg 'Release file has' 'no Date field, but Valid-Until expired'
84rm -rf rootdir/var/lib/apt/lists
85generatereleasefiles 'now' 'now - 2 days'
86sed -i '/^Date: / d' $(find ./aptarchive -name 'Release')
87signreleasefiles
88testfailure aptget update
89listcurrentlistsdirectory > listsdir.lst
90# have no effect as Date is unknown
91testfailure aptget update -o Acquire::Min-ValidTime=$((3600*24*30))
92testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
93testfailure aptget update -o Acquire::Max-ValidTime=1
94testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
95
96msgmsg 'Release file has' 'no Date field, but Valid-Until is good'
97rm -rf rootdir/var/lib/apt/lists
98generatereleasefiles 'now' 'now + 2 days'
99sed -i '/^Date: / d' $(find ./aptarchive -name 'Release')
100signreleasefiles
101testwarning aptget update