Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove perl from tests #1184

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,16 @@ def test_open_in_dvm_desktop(self):
self.assertIn(line, contents)

def test_mimeapps(self):
cmd = "perl -F= -lane 'print $F[1]' /usr/share/applications/mimeapps.list | sort | uniq -c"
results = self._run(cmd)
expected_results = "2 \n 295 open-in-dvm.desktop;"
self.assertEqual(results, expected_results)

def test_mimeapps_functional(self):
cmd = "perl -F= -lane 'print $F[0]' /usr/share/applications/mimeapps.list"
results = self._run(cmd)
for line in results.split("\n"):
if line != "[Default Applications]" and not line.startswith("#"):
actual_app = self._run(f"xdg-mime query default {line}")
self.assertEqual(actual_app, "open-in-dvm.desktop")
results = self._run("cat /usr/share/applications/mimeapps.list")
for line in results.splitlines():
if line.startswith(("#", "[Default")):
# Skip comments and the leading [Default Applications]
continue
mime, target = line.split("=", 1)
self.assertEqual(target, "open-in-dvm.desktop;")
# Now functionally test it
actual_app = self._run(f"xdg-mime query default {mime}")
self.assertEqual(actual_app, "open-in-dvm.desktop")

def test_mailcap_hardened(self):
self.mailcap_hardened()
Expand Down
18 changes: 11 additions & 7 deletions tests/test_proxy_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ def test_whonix_ws_repo_absent(self):
def test_logging_configured(self):
self.logging_configured()

def test_mime_types(self):
cmd = "perl -F= -lane 'print $F[0]' /usr/share/applications/mimeapps.list"
results = self._run(cmd)
for line in results.split("\n"):
if line != "[Default Applications]" and not line.startswith("#"):
actual_app = self._run(f"xdg-mime query default {line}")
self.assertEqual(actual_app, "open-in-dvm.desktop")
def test_mimeapps(self):
results = self._run("cat /usr/share/applications/mimeapps.list")
for line in results.splitlines():
if line.startswith(("#", "[Default")):
# Skip comments and the leading [Default Applications]
continue
mime, target = line.split("=", 1)
self.assertEqual(target, "open-in-dvm.desktop;")
# Now functionally test it
actual_app = self._run(f"xdg-mime query default {mime}")
self.assertEqual(actual_app, "open-in-dvm.desktop")

def test_mailcap_hardened(self):
self.mailcap_hardened()
Expand Down
16 changes: 7 additions & 9 deletions tests/test_vms_platform.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import json
import os
import re
import subprocess
import unittest

from base import CURRENT_FEDORA_TEMPLATE, SD_VMS
from qubesadmin import Qubes

BULLSEYE_STRING = "Debian GNU/Linux 11 (bullseye)"
BOOKWORM_STRING = "Debian GNU/Linux 12 (bookworm)"

SUPPORTED_SD_DEBIAN_DIST = "bookworm"
Expand All @@ -28,15 +28,13 @@ def tearDown(self):

def _get_platform_info(self, vm):
"""
Retrieve base OS for running AppVM. Executes command on AppVM
and returns the PRETTY_NAME field from /etc/os-release.
Retrieve PRETTY_NAME for an AppVM.
"""
# Not using `lsb_release` for platform info, because it is not present
# on Qubes AppVMs. Rather than install it simply for testing purposes,
# let's maintain the default config and retrieve the value elsewise.
cmd = "perl -nE '/^PRETTY_NAME=\"(.*)\"$/ and say $1' /etc/os-release"
stdout, stderr = vm.run(cmd)
return stdout.decode("utf-8").rstrip("\n")
stdout, stderr = vm.run("cat /etc/os-release")
search = re.search(r'^PRETTY_NAME="(.*)"', stdout.decode())
if not search:
raise RuntimeError(f"Unable to determine platform for {vm.name}")
return search.group(1)

def _validate_vm_platform(self, vm):
"""
Expand Down