예제 #1
0
 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)
예제 #2
0
 def test_create_uefi_keys_autokey_off(self):
     # Keys are not created.
     self.setUpUefiKeys(create=False)
     self.assertFalse(os.path.exists(self.key))
     self.assertFalse(os.path.exists(self.cert))
     fake_call = FakeMethod(result=0)
     self.useFixture(MonkeyPatch("subprocess.call", fake_call))
     upload = SigningUpload()
     upload.callLog = FakeMethodCallLog(upload=upload)
     upload.setTargetDirectory(self.archive, "test_1.0_amd64.tar.gz",
                               "distroseries")
     upload.signUefi(os.path.join(self.makeTemporaryDirectory(), 't.efi'))
     self.assertEqual(0, upload.callLog.caller_count('UEFI keygen'))
     self.assertFalse(os.path.exists(self.key))
     self.assertFalse(os.path.exists(self.cert))
예제 #3
0
    def process(self):
        self.tarfile.close()
        self.buffer.close()
        upload = SigningUpload()
        upload.signUefi = FakeMethod()
        upload.signKmod = FakeMethod()
        upload.signOpal = FakeMethod()
        # Under no circumstances is it safe to execute actual commands.
        fake_call = FakeMethod(result=0)
        self.useFixture(MonkeyPatch("subprocess.call", fake_call))
        upload.process(self.archive, self.path, self.suite)
        self.assertEqual(0, fake_call.call_count)

        return upload
예제 #4
0
 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)