Skip to content

Commit

Permalink
Test that apt interprets our .sources files correctly
Browse files Browse the repository at this point in the history
Run `apt-get indextargets` to verify that our .sources files are valid
and apt is able to properly interpret them.

I didn't implement actually running apt to check that we can download
files because that happens during provisioning already.
  • Loading branch information
legoktm committed Jun 18, 2024
1 parent 2352953 commit f98bb14
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions tests/test_vms_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import subprocess
import unittest

from base import CURRENT_FEDORA_TEMPLATE, WANTED_VMS
from base import CURRENT_FEDORA_TEMPLATE, CURRENT_WHONIX_VERSION, WANTED_VMS
from qubesadmin import Qubes

BULLSEYE_STRING = "Debian GNU/Linux 11 (bullseye)"
Expand Down Expand Up @@ -180,21 +180,37 @@ def test_dispvm_default_platform(self):
result = subprocess.check_output(cmd).decode("utf-8").rstrip("\n")
self.assertEqual(result, "sd-viewer")

def test_all_sd_vm_apt_sources(self):
def test_sd_vm_apt_sources(self):
"""
Test all VMs fpf apt source list iteratively.
Due to for-loop implementation, the first failure will stop the test.
Therefore, even if multiple VMs are NOT running a supported platform,
only a single failure will be reported.
Test that the three templates we install our apt sources into are correct
"""
for vm_name in WANTED_VMS:
if vm_name == "sd-viewer":
# sd-viewer is unable to start because of the securedrop-mime-handling
# systemd service failing, so skip it here.
continue
for vm_name in [
f"sd-small-{SUPPORTED_SD_DEBIAN_DIST}-template",
f"sd-large-{SUPPORTED_SD_DEBIAN_DIST}-template",
f"whonix-gateway-{CURRENT_WHONIX_VERSION}",
]:
vm = self.app.domains[vm_name]
# First verify it looks like what we provisioned
self._validate_apt_sources(vm)
stdout, stderr = vm.run("apt-get indextargets")
contents = stdout.decode().strip()
self.assertIn(
"Description: https://apt.freedom.press bookworm/main amd64 Packages\n", contents
)
if self.config["environment"] == "prod":
# prod setups shouldn't have any apt-test sources
self.assertNotIn("apt-test.freedom.press", contents)
else:
# staging/dev
test_components = ["main"]
if self.config["environment"] == "dev":
test_components.append("nightlies")
for component in test_components:
self.assertIn(
f"Description: https://apt-test.freedom.press bookworm/{component} "
"amd64 Packages\n",
contents,
)


def load_tests(loader, tests, pattern):
Expand Down

0 comments on commit f98bb14

Please sign in to comment.