summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2025-01-28 18:49:12 +0000
committerJulian Andres Klode <jak@debian.org>2025-01-28 18:49:12 +0000
commit37916ecaa4718350a3c66130b356a076a24ca6e2 (patch)
tree5307e3c7111d8db56608767806f68b0d97a489ee /test
parentd9f7d2c37023d186be4a21a4d714e032be48e315 (diff)
parent827d60f3cf1ffe0a11b17ce9d1f22bb4a1c6aded (diff)
Merge branch 'modernize-sources' into 'main'
apt: Introduce the modernize-sources command See merge request apt-team/apt!438
Diffstat (limited to 'test')
-rwxr-xr-xtest/integration/test-apt-get-update-sourceslist-warning20
-rwxr-xr-xtest/integration/test-apt-modernize-sources85
2 files changed, 97 insertions, 8 deletions
diff --git a/test/integration/test-apt-get-update-sourceslist-warning b/test/integration/test-apt-get-update-sourceslist-warning
index 7e27e4825..5a941dae6 100755
--- a/test/integration/test-apt-get-update-sourceslist-warning
+++ b/test/integration/test-apt-get-update-sourceslist-warning
@@ -46,14 +46,18 @@ msgmsg 'Detect login info embedded in sources.list'
echo 'deb http://apt:debian@example.org/debian bookworm main' > rootdir/etc/apt/sources.list.d/example.list
testsuccessequal "$BOILERPLATE
N: Usage of apt_auth.conf(5) should be preferred over embedding login information directly in the sources.list(5) entry for 'http://example.org/debian'
-N: Missing Signed-By in the sources.list(5) entry for 'http://example.org/debian'
-N: Consider migrating all sources.list(5) entries to the deb822 .sources format
-N: The deb822 .sources format supports both embedded as well as external OpenPGP keys
-N: See apt-secure(8) for best practices in configuring repository signing." apt update --no-download
+A: The sources.list(5) entry for 'http://example.org/debian' should be upgraded to deb822 .sources
+A: Missing Signed-By in the sources.list(5) entry for 'http://example.org/debian'
+A: Consider migrating all sources.list(5) entries to the deb822 .sources format
+A: The deb822 .sources format supports both embedded as well as external OpenPGP keys
+A: See apt-secure(8) for best practices in configuring repository signing.
+N: Some sources can be modernized. Run 'apt modernize-sources' to do so." apt update --no-download --audit
echo 'deb tor+https://apt:debian@example.org/debian bookworm main' > rootdir/etc/apt/sources.list.d/example.list
testsuccessequal "$BOILERPLATE
N: Usage of apt_auth.conf(5) should be preferred over embedding login information directly in the sources.list(5) entry for 'tor+https://example.org/debian'
-N: Missing Signed-By in the sources.list(5) entry for 'tor+https://example.org/debian'
-N: Consider migrating all sources.list(5) entries to the deb822 .sources format
-N: The deb822 .sources format supports both embedded as well as external OpenPGP keys
-N: See apt-secure(8) for best practices in configuring repository signing." apt update --no-download
+A: The sources.list(5) entry for 'tor+https://example.org/debian' should be upgraded to deb822 .sources
+A: Missing Signed-By in the sources.list(5) entry for 'tor+https://example.org/debian'
+A: Consider migrating all sources.list(5) entries to the deb822 .sources format
+A: The deb822 .sources format supports both embedded as well as external OpenPGP keys
+A: See apt-secure(8) for best practices in configuring repository signing.
+N: Some sources can be modernized. Run 'apt modernize-sources' to do so." apt update --no-download --audit
diff --git a/test/integration/test-apt-modernize-sources b/test/integration/test-apt-modernize-sources
new file mode 100755
index 000000000..26fd8055a
--- /dev/null
+++ b/test/integration/test-apt-modernize-sources
@@ -0,0 +1,85 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+
+setupenvironment
+configarchitecture 'native'
+
+echo 'deb http://example.org/debian stable rocks' > rootdir/etc/apt/sources.list.d/rocks.list
+echo 'deb http://deb.debian.org/debian stable main' >> rootdir/etc/apt/sources.list
+echo 'deb-src http://deb.debian.org/debian stable main' >> rootdir/etc/apt/sources.list
+echo 'deb-src http://deb.debian.org/debian unstable main' >> rootdir/etc/apt/sources.list
+echo 'deb http://example.org/debian stable bananas' >> rootdir/etc/apt/sources.list
+echo 'deb [trusted=yes] http://example.org/debian trusted bananas' >> rootdir/etc/apt/sources.list
+
+
+mkdir -p rootdir/usr/share/keyrings/
+mkdir -p rootdir/var/lib/apt/lists
+echo > rootdir/etc/apt/trusted.gpg.d/rocks.gpg
+echo > rootdir/usr/share/keyrings/debian-archive-keyring.gpg
+echo "Date: $(date -ud '-2 weeks' '+%a, %d %b %Y %H:%M:%S %Z')" > rootdir/var/lib/apt/lists/deb.debian.org_debian_dists_unstable_InRelease
+echo "Date: $(date -ud '-2 weeks' '+%a, %d %b %Y %H:%M:%S %Z')" > rootdir/var/lib/apt/lists/deb.debian.org_debian_dists_stable_InRelease
+echo "Origin: Debian" >> rootdir/var/lib/apt/lists/deb.debian.org_debian_dists_unstable_InRelease
+echo "Origin: Debian" >> rootdir/var/lib/apt/lists/deb.debian.org_debian_dists_stable_InRelease
+
+# We test that appending produces valid output here, so we already configure a source in here.
+echo "Types: deb" >> rootdir/etc/apt/sources.list.d/debian.sources
+echo "URIs: https://deb.debian.org/debian/" >> rootdir/etc/apt/sources.list.d/debian.sources
+echo "Suites: experimental" >> rootdir/etc/apt/sources.list.d/debian.sources
+echo "Components: contrib" >> rootdir/etc/apt/sources.list.d/debian.sources
+echo "Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg" >> rootdir/etc/apt/sources.list.d/debian.sources
+
+testwarning apt modernize-sources -y
+
+testsuccessequal "rootdir/etc/apt/sources.list.bak
+
+rootdir/etc/apt/sources.list.d:
+debian.sources
+moved-from-main.sources
+rocks.list.bak
+rocks.sources" ls -1 rootdir/etc/apt/sources.list*
+
+testfileequal rootdir/etc/apt/sources.list.d/debian.sources "Types: deb
+URIs: https://deb.debian.org/debian/
+Suites: experimental
+Components: contrib
+Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
+
+# Modernized from ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/sources.list
+Types: deb deb-src
+URIs: http://deb.debian.org/debian/
+Suites: stable
+Components: main
+Signed-By: ${TMPWORKINGDIRECTORY}/rootdir/usr/share/keyrings/debian-archive-keyring.gpg
+
+# Modernized from ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/sources.list
+Types: deb-src
+URIs: http://deb.debian.org/debian/
+Suites: unstable
+Components: main
+Signed-By: ${TMPWORKINGDIRECTORY}/rootdir/usr/share/keyrings/debian-archive-keyring.gpg"
+
+testfileequal rootdir/etc/apt/sources.list.d/rocks.sources "Types: deb
+URIs: http://example.org/debian/
+Suites: stable
+Components: rocks
+Signed-By: ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/trusted.gpg.d/rocks.gpg"
+
+testfileequal rootdir/etc/apt/sources.list.d/moved-from-main.sources "# Modernized from ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/sources.list
+Types: deb
+URIs: http://example.org/debian/
+Suites: stable
+Components: bananas
+Signed-By:
+
+# Modernized from ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/sources.list
+Types: deb
+URIs: http://example.org/debian/
+Suites: trusted
+Components: bananas
+Signed-By:
+Trusted: yes"
+
+testsuccessequal "All sources are modern." apt modernize-sources