def test_correct_uefi_keygen_command_executed(self): # Check that calling generateUefiKeys() will generate the # expected command. self.setUpPPA() self.setUpUefiKeys(create=False) fake_call = FakeMethod(result=0) self.useFixture(MonkeyPatch("subprocess.call", fake_call)) upload = SigningUpload() upload.setTargetDirectory(self.archive, "test_1.0_amd64.tar.gz", "distroseries") upload.generateUefiKeys() self.assertEqual(1, fake_call.call_count) # Assert the actual command matches. args = fake_call.calls[0][0][0] expected_cmd = [ 'openssl', 'req', '-new', '-x509', '-newkey', 'rsa:2048', '-subj', self.testcase_cn, '-keyout', self.key, '-out', self.cert, '-days', '3650', '-nodes', '-sha256', ] self.assertEqual(expected_cmd, args)
def test_correct_uefi_signing_command_executed_no_keys(self): # Check that calling signUefi() will generate no commands when # no keys are present. self.setUpUefiKeys(create=False) fake_call = FakeMethod(result=0) self.useFixture(MonkeyPatch("subprocess.call", fake_call)) upload = SigningUpload() upload.generateUefiKeys = FakeMethod() upload.setTargetDirectory(self.archive, "test_1.0_amd64.tar.gz", "distroseries") upload.signUefi('t.efi') self.assertEqual(0, fake_call.call_count) self.assertEqual(0, upload.generateUefiKeys.call_count)
def test_correct_uefi_signing_command_executed(self): # Check that calling signUefi() will generate the expected command # when appropriate keys are present. self.setUpUefiKeys() fake_call = FakeMethod(result=0) self.useFixture(MonkeyPatch("subprocess.call", fake_call)) upload = SigningUpload() upload.generateUefiKeys = FakeMethod() upload.setTargetDirectory(self.archive, "test_1.0_amd64.tar.gz", "distroseries") upload.signUefi('t.efi') self.assertEqual(1, fake_call.call_count) # Assert command form. args = fake_call.calls[0][0][0] expected_cmd = [ 'sbsign', '--key', self.key, '--cert', self.cert, 't.efi', ] self.assertEqual(expected_cmd, args) self.assertEqual(0, upload.generateUefiKeys.call_count)