def process_emulate(self):
        self.tarfile.close()
        self.buffer.close()
        upload = SigningUpload()
        # Under no circumstances is it safe to execute actual commands.
        self.fake_call = FakeMethod(result=0)
        upload.callLog = FakeMethodCallLog(upload=upload)
        self.useFixture(MonkeyPatch("subprocess.call", self.fake_call))
        upload.process(self.archive, self.path, self.suite)

        return upload
 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))
 def test_create_opal_keys_autokey_on(self):
     # Keys are created on demand.
     self.setUpPPA()
     self.setUpOpalKeys(create=False)
     self.assertFalse(os.path.exists(self.opal_pem))
     self.assertFalse(os.path.exists(self.opal_x509))
     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.signOpal(os.path.join(self.makeTemporaryDirectory(), 't.opal'))
     self.assertEqual(1, upload.callLog.caller_count('Opal keygen key'))
     self.assertEqual(1, upload.callLog.caller_count('Opal keygen cert'))
     self.assertTrue(os.path.exists(self.opal_pem))
     self.assertTrue(os.path.exists(self.opal_x509))
     self.assertEqual(stat.S_IMODE(os.stat(self.opal_pem).st_mode), 0o600)
     self.assertEqual(stat.S_IMODE(os.stat(self.opal_x509).st_mode), 0o644)