Example #1
0
 def test_correct_opal_signing_command_executed_no_keys(self):
     # Check that calling signOpal() will generate no commands when
     # no keys are present.
     self.setUpOpalKeys(create=False)
     fake_call = FakeMethod(result=0)
     self.useFixture(MonkeyPatch("subprocess.call", fake_call))
     upload = SigningUpload()
     upload.generateOpalKeys = FakeMethod()
     upload.setTargetDirectory(self.archive, "test_1.0_amd64.tar.gz",
                               "distroseries")
     upload.signOpal('t.opal')
     self.assertEqual(0, fake_call.call_count)
     self.assertEqual(0, upload.generateOpalKeys.call_count)
Example #2
0
 def test_create_opal_keys_autokey_off(self):
     # Keys are not created.
     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(0, upload.callLog.caller_count('Opal keygen key'))
     self.assertEqual(0, upload.callLog.caller_count('Opal keygen cert'))
     self.assertFalse(os.path.exists(self.opal_pem))
     self.assertFalse(os.path.exists(self.opal_x509))
Example #3
0
 def test_correct_opal_signing_command_executed(self):
     # Check that calling signOpal() will generate the expected command
     # when appropriate keys are present.
     self.setUpOpalKeys()
     fake_call = FakeMethod(result=0)
     self.useFixture(MonkeyPatch("subprocess.call", fake_call))
     upload = SigningUpload()
     upload.generateOpalKeys = FakeMethod()
     upload.setTargetDirectory(self.archive, "test_1.0_amd64.tar.gz",
                               "distroseries")
     upload.signOpal('t.opal')
     self.assertEqual(1, fake_call.call_count)
     # Assert command form.
     args = fake_call.calls[0][0][0]
     expected_cmd = [
         'kmodsign', '-D', 'sha512', self.opal_pem, self.opal_x509,
         't.opal', 't.opal.sig'
     ]
     self.assertEqual(expected_cmd, args)
     self.assertEqual(0, upload.generateOpalKeys.call_count)
Example #4
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