Skip to content

Commit

Permalink
Merge pull request #1093 from freedomofpress/apt-sources
Browse files Browse the repository at this point in the history
Test that apt interprets our .sources files correctly
  • Loading branch information
cfm authored Oct 1, 2024
2 parents 94d36d6 + 44ed477 commit 1bb836d
Showing 1 changed file with 34 additions and 12 deletions.
46 changes: 34 additions & 12 deletions tests/test_vms_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
import subprocess
import unittest

from base import CURRENT_FEDORA_TEMPLATE, SD_VMS
from base import (
CURRENT_FEDORA_TEMPLATE,
CURRENT_WHONIX_VERSION,
SD_TEMPLATE_LARGE,
SD_TEMPLATE_SMALL,
SD_VMS,
)
from qubesadmin import Qubes

BULLSEYE_STRING = "Debian GNU/Linux 11 (bullseye)"
Expand Down Expand Up @@ -180,21 +186,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 SD_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 [
SD_TEMPLATE_SMALL,
SD_TEMPLATE_LARGE,
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 1bb836d

Please sign in to comment.