diff --git a/launcher/sdw_updater_gui/Updater.py b/launcher/sdw_updater_gui/Updater.py index 34cd05fc5..5f8cca5e0 100644 --- a/launcher/sdw_updater_gui/Updater.py +++ b/launcher/sdw_updater_gui/Updater.py @@ -31,6 +31,8 @@ # logic to leverage the Qubes Python API. MIGRATION_DIR = "/tmp/sdw-migrations" # nosec +DEBIAN_VERSION = "bullseye" + sdlog = Util.get_logger(module=__name__) detail_log = Util.get_logger(prefix=DETAIL_LOGGER_PREFIX, module=__name__) @@ -39,13 +41,13 @@ # In the future, we could use qvm-prefs to extract this information. current_vms = { "fedora": "fedora-35", - "sd-viewer": "sd-large-buster-template", - "sd-app": "sd-small-buster-template", - "sd-log": "sd-small-buster-template", - "sd-devices": "sd-large-buster-template", - "sd-proxy": "sd-small-buster-template", + "sd-viewer": "sd-large-{}-template".format(DEBIAN_VERSION), + "sd-app": "sd-small-{}-template".format(DEBIAN_VERSION), + "sd-log": "sd-small-{}-template".format(DEBIAN_VERSION), + "sd-devices": "sd-large-{}-template".format(DEBIAN_VERSION), + "sd-proxy": "sd-small-{}-template".format(DEBIAN_VERSION), "sd-whonix": "whonix-gw-16", - "sd-gpg": "sd-small-buster-template", + "sd-gpg": "sd-small-{}-template".format(DEBIAN_VERSION), } current_templates = set([val for key, val in current_vms.items() if key != "dom0"]) diff --git a/launcher/tests/fixtures/os-release-qubes-4.0 b/launcher/tests/fixtures/os-release-qubes-4.0 deleted file mode 100644 index 567f34649..000000000 --- a/launcher/tests/fixtures/os-release-qubes-4.0 +++ /dev/null @@ -1,7 +0,0 @@ -NAME=Qubes -VERSION="4.0 (R4.0)" -ID=qubes -VERSION_ID=4.0 -PRETTY_NAME="Qubes 4.0 (R4.0)" -ANSI_COLOR="0;31" -CPE_NAME="cpe:/o:ITL:qubes:4.0" diff --git a/launcher/tests/test_updater.py b/launcher/tests/test_updater.py index a672c9b0e..7d5c5a9dc 100644 --- a/launcher/tests/test_updater.py +++ b/launcher/tests/test_updater.py @@ -27,6 +27,8 @@ "sd-devices", ] +DEBIAN_VERSION = "bullseye" + TEST_RESULTS_OK = { "dom0": UpdateStatus.UPDATES_OK, "fedora": UpdateStatus.UPDATES_OK, @@ -491,8 +493,8 @@ def test_shutdown_and_start_vms( ] template_vm_calls = [ call("fedora-35"), - call("sd-large-buster-template"), - call("sd-small-buster-template"), + call("sd-large-{}-template".format(DEBIAN_VERSION)), + call("sd-small-{}-template".format(DEBIAN_VERSION)), call("whonix-gw-16"), ] app_vm_calls = [ @@ -537,8 +539,8 @@ def test_shutdown_and_start_vms_sysvm_fail( ] template_vm_calls = [ call("fedora-35"), - call("sd-large-buster-template"), - call("sd-small-buster-template"), + call("sd-large-{}-template".format(DEBIAN_VERSION)), + call("sd-small-{}-template".format(DEBIAN_VERSION)), call("whonix-gw-16"), ] error_calls = [ diff --git a/launcher/tests/test_util.py b/launcher/tests/test_util.py index 1d7d367df..c91f789f8 100644 --- a/launcher/tests/test_util.py +++ b/launcher/tests/test_util.py @@ -22,6 +22,8 @@ path_to_util = os.path.join(os.path.dirname(os.path.abspath(__file__)), relpath_util) util = SourceFileLoader("Util", path_to_util).load_module() +DEBIAN_VERSION = "bullseye" + @mock.patch("Util.sdlog.error") @mock.patch("Util.sdlog.warning") @@ -200,7 +202,6 @@ def test_for_conflicting_process( @pytest.mark.parametrize( "os_release_fixture,version_contains", [ - ("os-release-qubes-4.0", "4.0"), ("os-release-qubes-4.1", "4.1"), ("os-release-ubuntu", None), ("no-such-file", None), @@ -209,7 +210,7 @@ def test_for_conflicting_process( @mock.patch("Util.sdlog.error") @mock.patch("Util.sdlog.warning") @mock.patch("Util.sdlog.info") -@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0")) +@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1")) def test_detect_qubes( mocked_info, mocked_warning, mocked_error, os_release_fixture, version_contains ): @@ -232,7 +233,6 @@ def test_detect_qubes( @pytest.mark.parametrize( "os_release_fixture,expected_qt_version", [ - ("os-release-qubes-4.0", 4), ("os-release-qubes-4.1", 5), ("os-release-ubuntu", 4), ("no-such-file", 4), @@ -242,7 +242,7 @@ def test_detect_qubes( @mock.patch("Util.sdlog.error") @mock.patch("Util.sdlog.warning") @mock.patch("Util.sdlog.info") -@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0")) +@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1")) def test_pick_qt( mocked_info, mocked_warning, @@ -282,7 +282,7 @@ def test_pick_bad_qt(mocked_info, mocked_warning, mocked_error, env_override): """ mocked_env = {"SDW_UPDATER_QT": env_override} with mock.patch.dict("os.environ", mocked_env), mock.patch( - "Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0") + "Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1") ), pytest.raises(ValueError): util.get_qt_version() @@ -303,13 +303,12 @@ def test_get_logger(): @pytest.mark.parametrize( "os_release_fixture,version_contains", [ - ("os-release-qubes-4.0", "4.0"), ("os-release-qubes-4.1", "4.1"), ("os-release-ubuntu", None), ("no-such-file", None), ], ) -@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0")) +@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1")) def test_is_sdapp_halted_yes(os_release_fixture, version_contains): """ When sd-app state is 'Halted' @@ -317,7 +316,7 @@ def test_is_sdapp_halted_yes(os_release_fixture, version_contains): """ output = bytes( "NAME STATE CLASS LABEL TEMPLATE\nsd-app" - " Halted AppVM yellow sd-small-buster-template\n", + " Halted AppVM yellow sd-small-{}-template\n".format(DEBIAN_VERSION), "utf-8", ) @@ -329,13 +328,12 @@ def test_is_sdapp_halted_yes(os_release_fixture, version_contains): @pytest.mark.parametrize( "os_release_fixture,version_contains", [ - ("os-release-qubes-4.0", "4.0"), ("os-release-qubes-4.1", "4.1"), ("os-release-ubuntu", None), ("no-such-file", None), ], ) -@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0")) +@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1")) def test_is_sdapp_halted_no(os_release_fixture, version_contains): """ When sd-app is not Halted (i.e. Running, Pasued) @@ -343,7 +341,7 @@ def test_is_sdapp_halted_no(os_release_fixture, version_contains): """ output = bytes( "NAME STATE CLASS LABEL TEMPLATE\nsd-app" - " Paused AppVM yellow sd-small-buster-template\n", + " Paused AppVM yellow sd-small-{}-template\n".format(DEBIAN_VERSION), "utf-8", ) @@ -355,13 +353,12 @@ def test_is_sdapp_halted_no(os_release_fixture, version_contains): @pytest.mark.parametrize( "os_release_fixture,version_contains", [ - ("os-release-qubes-4.0", "4.0"), ("os-release-qubes-4.1", "4.1"), ("os-release-ubuntu", None), ("no-such-file", None), ], ) -@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0")) +@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1")) @mock.patch("subprocess.check_output", side_effect=subprocess.CalledProcessError(1, "check_output")) def test_is_sdapp_halted_error(patched_subprocess, os_release_fixture, version_contains): """