qvm-template: fix downloading template for install

Donwload a template into a cache dir, not into default of `qvm-template
download` (current directory).
This commit is contained in:
Marek Marczykowski-Górecki 2021-04-01 01:31:35 +02:00
parent d1ce8d3a95
commit 9020f2e1fd
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 12 additions and 0 deletions

View File

@ -300,6 +300,7 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase):
]) ])
# Nothing downloaded # Nothing downloaded
mock_dl.assert_called_with(args, self.app, mock_dl.assert_called_with(args, self.app,
path_override='/var/cache/qvm-template',
dl_list={}, version_selector=selector) dl_list={}, version_selector=selector)
mock_verify.assert_called_once_with(template_file.name, '/tmp/keyring.gpg', mock_verify.assert_called_once_with(template_file.name, '/tmp/keyring.gpg',
nogpgcheck=False) nogpgcheck=False)
@ -409,6 +410,7 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase):
]) ])
# Nothing downloaded # Nothing downloaded
mock_dl.assert_called_with(args, self.app, mock_dl.assert_called_with(args, self.app,
path_override='/var/cache/qvm-template',
dl_list={}, version_selector=selector) dl_list={}, version_selector=selector)
# Package is extracted # Package is extracted
mock_extract.assert_called_with('test-vm', path, mock_extract.assert_called_with('test-vm', path,
@ -554,6 +556,7 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase):
# Nothing downloaded # Nothing downloaded
self.assertEqual(mock_dl.mock_calls, [ self.assertEqual(mock_dl.mock_calls, [
mock.call(args, self.app, mock.call(args, self.app,
path_override='/var/cache/qvm-template',
dl_list={}, version_selector=selector) dl_list={}, version_selector=selector)
]) ])
# Should not be executed: # Should not be executed:
@ -762,6 +765,7 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase):
mock.call(args, self.app, version_selector=selector) mock.call(args, self.app, version_selector=selector)
]) ])
mock_dl.assert_called_with(args, self.app, mock_dl.assert_called_with(args, self.app,
path_override='/var/cache/qvm-template',
dl_list=dl_list, version_selector=selector) dl_list=dl_list, version_selector=selector)
# download already verify the package internally # download already verify the package internally
self.assertEqual(mock_verify.mock_calls, []) self.assertEqual(mock_verify.mock_calls, [])
@ -863,6 +867,7 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase):
]) ])
# Nothing downloaded nor installed # Nothing downloaded nor installed
mock_dl.assert_called_with(args, self.app, mock_dl.assert_called_with(args, self.app,
path_override='/var/cache/qvm-template',
dl_list={}, version_selector=selector) dl_list={}, version_selector=selector)
mock_verify.assert_not_called() mock_verify.assert_not_called()
mock_extract.assert_not_called() mock_extract.assert_not_called()
@ -943,6 +948,7 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase):
]) ])
# Nothing downloaded # Nothing downloaded
mock_dl.assert_called_with(args, self.app, mock_dl.assert_called_with(args, self.app,
path_override='/var/cache/qvm-template',
dl_list={}, version_selector=selector) dl_list={}, version_selector=selector)
mock_verify.assert_called_once_with(template_file.name, mock_verify.assert_called_once_with(template_file.name,
'/tmp/keyring.gpg', '/tmp/keyring.gpg',
@ -4042,6 +4048,7 @@ test-vm : Qubes template for fedora-31
mock.call(args, self.app, version_selector=selector) mock.call(args, self.app, version_selector=selector)
]) ])
mock_dl.assert_called_with(args, self.app, mock_dl.assert_called_with(args, self.app,
path_override='/var/cache/qvm-template',
dl_list=dl_list, version_selector=selector) dl_list=dl_list, version_selector=selector)
# already verified by download() # already verified by download()
self.assertEqual(mock_verify.mock_calls, []) self.assertEqual(mock_verify.mock_calls, [])
@ -4148,6 +4155,7 @@ test-vm : Qubes template for fedora-31
mock.call(args, self.app, version_selector=selector) mock.call(args, self.app, version_selector=selector)
]) ])
mock_dl.assert_called_with(args, self.app, mock_dl.assert_called_with(args, self.app,
path_override='/var/cache/qvm-template',
dl_list=dl_list, version_selector=selector) dl_list=dl_list, version_selector=selector)
# already verified by download() # already verified by download()
self.assertEqual(mock_verify.mock_calls, []) self.assertEqual(mock_verify.mock_calls, [])
@ -4266,6 +4274,7 @@ test-vm : Qubes template for fedora-31
mock.call(args, self.app, version_selector=selector) mock.call(args, self.app, version_selector=selector)
]) ])
mock_dl.assert_called_with(args, self.app, mock_dl.assert_called_with(args, self.app,
path_override='/var/cache/qvm-template',
dl_list=dl_list, version_selector=selector) dl_list=dl_list, version_selector=selector)
# Expect override confirmation # Expect override confirmation
self.assertEqual(mock_confirm.mock_calls, self.assertEqual(mock_confirm.mock_calls,
@ -4662,6 +4671,7 @@ gpgkey = file:///etc/qubes/repo-templates/keys/RPM-GPG-KEY-qubes-$releasever-pri
mock.call(args, self.app, version_selector=selector) mock.call(args, self.app, version_selector=selector)
]) ])
mock_dl.assert_called_with(args, self.app, mock_dl.assert_called_with(args, self.app,
path_override='/var/cache/qvm-template',
dl_list={}, version_selector=selector) dl_list={}, version_selector=selector)
self.assertEqual(mock_verify.mock_calls, [ self.assertEqual(mock_verify.mock_calls, [
mock.call(template_file.name, '/tmp/keyring.gpg', nogpgcheck=False) mock.call(template_file.name, '/tmp/keyring.gpg', nogpgcheck=False)
@ -4747,6 +4757,7 @@ gpgkey = file:///etc/qubes/repo-templates/keys/RPM-GPG-KEY-qubes-$releasever-pri
mock.call(args, self.app, version_selector=selector) mock.call(args, self.app, version_selector=selector)
]) ])
mock_dl.assert_called_with(args, self.app, mock_dl.assert_called_with(args, self.app,
path_override='/var/cache/qvm-template',
dl_list={}, version_selector=selector) dl_list={}, version_selector=selector)
self.assertEqual(mock_verify.mock_calls, [ self.assertEqual(mock_verify.mock_calls, [
mock.call(template_file.name, '/tmp/keyring.gpg', nogpgcheck=False) mock.call(template_file.name, '/tmp/keyring.gpg', nogpgcheck=False)

View File

@ -996,6 +996,7 @@ def install(
package_hdrs = download(args, app, package_hdrs = download(args, app,
dl_list=dl_list, dl_list=dl_list,
path_override=args.cachedir,
version_selector=version_selector) version_selector=version_selector)
# Verify downloaded templates # Verify downloaded templates