]> git.saurik.com Git - apt.git/blobdiff - test/integration/test-apt-update-nofallback
implement generic config fallback for methods
[apt.git] / test / integration / test-apt-update-nofallback
index 4804b0ae60146c56588d7cc5034e92e87b063647..60f329a4a0e9c1cfb64091d808c42aa18b223048 100755 (executable)
@@ -9,8 +9,7 @@ set -e
 simulate_mitm_and_inject_evil_package()
 {
     redatereleasefiles '+1 hour'
-    rm -f "$APTARCHIVE/dists/unstable/InRelease"
-    rm -f "$APTARCHIVE/dists/unstable/Release.gpg"
+    rm -f "$APTARCHIVE/dists/unstable/InRelease" "$APTARCHIVE/dists/unstable/Release.gpg"
     inject_evil_package
 }
 
@@ -59,7 +58,7 @@ setupaptarchive_with_lists_clean()
 
 test_from_inrelease_to_unsigned()
 {
-    # setup archive with InRelease file
+    export APT_DONT_SIGN='Release.gpg'
     setupaptarchive_with_lists_clean
     testsuccess aptget update
     listcurrentlistsdirectory > lists.before
@@ -71,9 +70,8 @@ test_from_inrelease_to_unsigned()
 
 test_from_release_gpg_to_unsigned()
 {
-    # setup archive with Release/Release.gpg (but no InRelease)
+    export APT_DONT_SIGN='InRelease'
     setupaptarchive_with_lists_clean
-    rm "$APTARCHIVE/dists/unstable/InRelease"
     testsuccess aptget update
     listcurrentlistsdirectory > lists.before
 
@@ -84,6 +82,7 @@ test_from_release_gpg_to_unsigned()
 
 test_from_inrelease_to_unsigned_with_override()
 {
+    export APT_DONT_SIGN='Release.gpg'
     # setup archive with InRelease file
     setupaptarchive_with_lists_clean
     testsuccess aptget update
@@ -94,6 +93,36 @@ test_from_inrelease_to_unsigned_with_override()
     find "$APTARCHIVE" -name '*Packages*' -exec touch -d '+2 hours' {} \;
 
     # and ensure we can update to it (with enough force) 
+    testfailure apt update
+    testfailure aptget update
+    testfailure aptget update --allow-insecure-repositories
+    testfailure aptget update --no-allow-insecure-repositories
+    sed -i 's#^deb\(-src\)\? #deb\1 [allow-downgrade-to-insecure=yes] #' rootdir/etc/apt/sources.list.d/*
+    testfailure aptget update --no-allow-insecure-repositories
+    testfailure apt update
+    testwarning apt update --allow-insecure-repositories \
+        -o Debug::pkgAcquire::Worker=1 -o Debug::pkgAcquire::Auth=1
+    sed -i 's#^deb\(-src\)\? \[allow-downgrade-to-insecure=yes\] #deb\1 #' rootdir/etc/apt/sources.list.d/*
+    # but that the individual packages are still considered untrusted
+    testfailureequal "WARNING: The following packages cannot be authenticated!
+  evil
+E: There were unauthenticated packages and -y was used without --allow-unauthenticated" aptget install -qq -y evil
+}
+
+test_from_inrelease_to_norelease_with_override()
+{
+    # setup archive with InRelease file
+    setupaptarchive_with_lists_clean
+    testsuccess aptget update
+
+    # simulate moving to a unsigned but otherwise valid repo
+    simulate_mitm_and_inject_evil_package
+    find "$APTARCHIVE" -name '*Release*' -delete
+    find "$APTARCHIVE" -name '*Packages*' -exec touch -d '+2 hours' {} \;
+
+    # and ensure we can update to it (with enough force) 
+    testfailure aptget update
+    testfailure aptget update --allow-insecure-repositories
     testwarning aptget update --allow-insecure-repositories \
         -o Acquire::AllowDowngradeToInsecureRepositories=1 -o Debug::pkgAcquire::Worker=1 -o Debug::pkgAcquire::Auth=1
     # but that the individual packages are still considered untrusted
@@ -120,17 +149,16 @@ test_cve_2012_0214()
     #
     # Still worth having a regression test the simulates the condition
 
-    # setup archive with InRelease
+    export APT_DONT_SIGN='Release.gpg'
     setupaptarchive_with_lists_clean
     testsuccess aptget update
     listcurrentlistsdirectory > lists.before
 
     # do what CVE-2012-0214 did
-    rm "$APTARCHIVE/dists/unstable/InRelease"
-    rm "$APTARCHIVE/dists/unstable/Release.gpg"
+    rm -f "$APTARCHIVE/dists/unstable/InRelease" "$APTARCHIVE/dists/unstable/Release.gpg"
     inject_evil_package
     # build valid Release file
-    aptftparchive -qq release ./aptarchive > aptarchive/dists/unstable/Release 
+    aptftparchive -qq release ./aptarchive > aptarchive/dists/unstable/Release
 
     assert_update_is_refused_and_last_good_state_used
     testfileequal lists.before "$(listcurrentlistsdirectory)"
@@ -141,7 +169,7 @@ test_cve_2012_0214()
 
 test_subvert_inrelease()
 {
-    # setup archive with InRelease
+    export APT_DONT_SIGN='Release.gpg'
     setupaptarchive_with_lists_clean
     testsuccess aptget update
     listcurrentlistsdirectory > lists.before
@@ -149,7 +177,7 @@ test_subvert_inrelease()
     # replace InRelease with something else
     mv "$APTARCHIVE/dists/unstable/Release" "$APTARCHIVE/dists/unstable/InRelease"
 
-    testfailuremsg "W: Failed to fetch file:${APTARCHIVE}/dists/unstable/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
+    testfailuremsg "E: Failed to fetch file:${APTARCHIVE}/dists/unstable/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
 
     # ensure we keep the repo
@@ -159,7 +187,7 @@ E: Some index files failed to download. They have been ignored, or old ones used
 
 test_inrelease_to_invalid_inrelease()
 {
-    # setup archive with InRelease
+    export APT_DONT_SIGN='Release.gpg'
     setupaptarchive_with_lists_clean
     testsuccess aptget update
     listcurrentlistsdirectory > lists.before
@@ -180,9 +208,8 @@ W: Some index files failed to download. They have been ignored, or old ones used
 
 test_release_gpg_to_invalid_release_release_gpg()
 {
-    # setup archive with InRelease
+    export APT_DONT_SIGN='InRelease'
     setupaptarchive_with_lists_clean
-    rm "$APTARCHIVE/dists/unstable/InRelease"
     testsuccess aptget update
     listcurrentlistsdirectory > lists.before
 
@@ -240,3 +267,5 @@ test_release_gpg_to_invalid_release_release_gpg
 # ensure we can override the downgrade error
 msgmsg "test_from_inrelease_to_unsigned_with_override"
 test_from_inrelease_to_unsigned_with_override
+msgmsg "test_from_inrelease_to_norelease_with_override"
+test_from_inrelease_to_norelease_with_override