tests: fix tests for verify_rpm involving incorrect template names
This commit is contained in:
parent
ed3e368673
commit
33d205c1dd
@ -114,21 +114,22 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase):
|
|||||||
@mock.patch('subprocess.check_call')
|
@mock.patch('subprocess.check_call')
|
||||||
@mock.patch('subprocess.check_output')
|
@mock.patch('subprocess.check_output')
|
||||||
def test_004_verify_rpm_badname(self, mock_proc, mock_call, mock_ts):
|
def test_004_verify_rpm_badname(self, mock_proc, mock_call, mock_ts):
|
||||||
mock_proc.side_effect = subprocess.CalledProcessError(1,
|
mock_proc.return_value = b'/dev/null: digests signatures OK\n'
|
||||||
['rpmkeys', '--checksig'], b'/dev/null: digests signatures OK\n')
|
|
||||||
hdr = {
|
hdr = {
|
||||||
rpm.RPMTAG_SIGPGP: 'xxx', # non-empty
|
rpm.RPMTAG_SIGPGP: 'xxx', # non-empty
|
||||||
rpm.RPMTAG_SIGGPG: 'xxx', # non-empty
|
rpm.RPMTAG_SIGGPG: 'xxx', # non-empty
|
||||||
rpm.RPMTAG_NAME: 'qubes-template-unexpected',
|
rpm.RPMTAG_NAME: 'qubes-template-unexpected',
|
||||||
}
|
}
|
||||||
mock_ts.return_value.hdrFromFdno.return_value = hdr
|
mock_ts.return_value.hdrFromFdno.return_value = hdr
|
||||||
with self.assertRaises(Exception) as e:
|
with self.assertRaises(
|
||||||
|
qubesadmin.tools.qvm_template.SignatureVerificationError) as e:
|
||||||
qubesadmin.tools.qvm_template.verify_rpm('/dev/null',
|
qubesadmin.tools.qvm_template.verify_rpm('/dev/null',
|
||||||
'/path/to/key', template_name='test-vm')
|
'/path/to/key', template_name='test-vm')
|
||||||
mock_call.assert_called_once()
|
mock_call.assert_called_once()
|
||||||
mock_proc.assert_called_once()
|
mock_proc.assert_called_once()
|
||||||
self.assertIn('Signature verification failed', e.exception.args[0])
|
self.assertIn('package does not match expected template name',
|
||||||
mock_ts.assert_not_called()
|
e.exception.args[0])
|
||||||
|
mock_ts.assert_called_once()
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@mock.patch('subprocess.Popen')
|
@mock.patch('subprocess.Popen')
|
||||||
|
Loading…
Reference in New Issue
Block a user