]> git.saurik.com Git - apt.git/blobdiff - test/integration/test-policy-pinning
a pin of 1000 always means downgrade allowed
[apt.git] / test / integration / test-policy-pinning
index 97447b3307f0048a8d0295b43e45e9f7d49cb8d9..2675b51bc579f832ce2796bf84376940307a78b9 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 set -e
 
-local TESTDIR=$(readlink -f $(dirname $0))
+TESTDIR=$(readlink -f $(dirname $0))
 . $TESTDIR/framework
 
 setupenvironment
@@ -17,7 +17,7 @@ testequalpolicy() {
        local SP="$1"
        local AP="$2"
        shift 2
-       testequal "Package files:
+       testsuccessequal "Package files:
  $(echo "$SP" | awk '{ printf("%3s\n",$0) }') ${STATUS}
      release a=now
  $(echo "$AP" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/  Packages
@@ -25,30 +25,58 @@ testequalpolicy() {
 Pinned packages:" aptcache policy $*
 }
 
-aptget update -qq
-testequalpolicy 100 500
-testequalpolicy 990 500 -t now
+testglobalpolicy() {
+       aptgetupdate
 
-sed -i aptarchive/Release -e 1i"NotAutomatic: yes"
-rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
-aptget update -qq
+       testequalpolicy 100 500
+       testequalpolicy 990 500 -t now
 
-testequalpolicy 100 1 -o Test=NotAutomatic
-testequalpolicy 990 1 -o Test=NotAutomatic -t now
+       sed -i aptarchive/Release -e 1i"NotAutomatic: yes"
+       aptgetupdate
 
-sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes"
-rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
-aptget update -qq
+       testequalpolicy 100 1 -o Test=NotAutomatic
+       testequalpolicy 990 1 -o Test=NotAutomatic -t now
 
-testequalpolicy 100 100 -o Test=ButAutomaticUpgrades
-testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now
+       sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes"
+       aptgetupdate
 
-sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d'
-rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
-aptget update -qq
+       testequalpolicy 100 100 -o Test=ButAutomaticUpgrades
+       testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now
 
-testequalpolicy 100 500 -o Test=Automatic
-testequalpolicy 990 500 -o Test=Automatic -t now
+       sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d'
+       aptgetupdate
+
+       testequalpolicy 100 500 -o Test=Automatic
+       testequalpolicy 990 500 -o Test=Automatic -t now
+
+       sed -i aptarchive/Release -e '/NotAutomatic: / d' -e '/ButAutomaticUpgrades: / d'
+}
+
+msgmsg 'Test with not signed archive'
+aptgetupdate() {
+       rm -rf rootdir/var/lib/apt
+       testwarning aptget update  --allow-insecure-repositories
+}
+testglobalpolicy
+
+msgmsg 'Test with signed but no key in trusted'
+aptgetupdate() {
+       rm -rf rootdir/var/lib/apt
+       signreleasefiles 'Marvin Paranoid'
+       testwarning aptget update  --allow-insecure-repositories
+}
+testglobalpolicy
+
+# much the same tests will be executed below in more detail again for this one
+msgmsg 'Test with signed and valid key'
+aptgetupdate() {
+       rm -rf rootdir/var/lib/apt
+       signreleasefiles 'Joe Sixpack'
+       testsuccess aptget update
+}
+testglobalpolicy
+
+msgmsg 'Test with specific packages'
 
 buildsimplenativepackage "coolstuff" "all" "1.0" "stable"
 buildsimplenativepackage "coolstuff" "all" "2.0~bpo1" "backports"
@@ -86,7 +114,7 @@ testequalpolicycoolstuff() {
                shift
        fi
        shift 6
-       testequal "coolstuff:
+       testsuccessequal "coolstuff:
   Installed: $INSTALLED
   Candidate: $CANDIDATE
   ${PINVERSION}Version table:${BPO2ARCHIVE}
@@ -135,8 +163,7 @@ Pin-Priority: -1" > rootdir/etc/apt/preferences
 rm rootdir/etc/apt/preferences
 sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
 signreleasefiles
-rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
-aptget update -qq
+aptgetupdate
 
 testequalpolicycoolstuff "" "1.0" 1 500 0 "" -o Test=NotAutomatic
 testequalpolicycoolstuff "" "1.0" 1 990 0 "" -o Test=NotAutomatic -t stable
@@ -164,8 +191,7 @@ testequalpolicycoolstuff "" "1.0" 1 990 600 "2.0~bpo1" -o Test=NotAutomatic -t s
 rm rootdir/etc/apt/preferences
 sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
 signreleasefiles
-rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
-aptget update -qq
+aptgetupdate
 
 testequalpolicycoolstuff "" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
 testequalpolicycoolstuff "" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
@@ -191,16 +217,16 @@ testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=ButAutomat
 testequalpolicycoolstuff "" "1.0" 100 990 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t stable
 
 rm rootdir/etc/apt/preferences
-aptget install coolstuff -qq > /dev/null 2> /dev/null
+testsuccess aptget install coolstuff -y
 testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
-aptget dist-upgrade -qq > /dev/null 2> /dev/null
+testsuccess aptget dist-upgrade -y
 testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
 testequalpolicycoolstuff "1.0" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
 testequalpolicycoolstuff "1.0" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
 
-aptget install coolstuff -t backports -qq > /dev/null 2> /dev/null
+testsuccess aptget install coolstuff -t backports -y
 testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
-aptget dist-upgrade -qq > /dev/null 2> /dev/null
+testsuccess aptget dist-upgrade -y
 testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
 testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
 testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
@@ -211,8 +237,7 @@ setupaptarchive
 
 sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
 signreleasefiles
-rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
-aptget update -qq
+aptgetupdate
 
 testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 500 0 "" "2.0~bpo2" -o Test=NotAutomatic
 testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 990 0 "" "2.0~bpo2" -o Test=NotAutomatic -t stable
@@ -220,8 +245,7 @@ testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=N
 
 sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
 signreleasefiles
-rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
-aptget update -qq
+aptgetupdate
 
 testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades
 testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 990 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t stable