Exemplo n.º 1
0
 def test_sign_with_signing_key(self):
     filename = os.path.join(getPubConfig(self.archive).archiveroot, "file")
     write_file(filename, "contents")
     self.assertIsNone(self.archive.signing_key)
     self.useFixture(InProcessKeyServerFixture()).start()
     key_path = os.path.join(gpgkeysdir, '*****@*****.**')
     yield IArchiveSigningKey(self.archive).setSigningKey(
         key_path, async_keyserver=True)
     self.assertIsNotNone(self.archive.signing_key)
     custom_processor = CustomUpload()
     custom_processor.sign(self.archive, "suite", filename)
     with open(filename) as cleartext_file:
         cleartext = cleartext_file.read()
         with open("%s.gpg" % filename) as signature_file:
             signature = getUtility(IGPGHandler).getVerifiedSignature(
                 cleartext, signature_file.read())
     self.assertEqual(self.archive.signing_key.fingerprint,
                      signature.fingerprint)
Exemplo n.º 2
0
 def test_sign_with_external_run_parts(self):
     self.enableRunParts(distribution_name=self.distro.name)
     archiveroot = getPubConfig(self.archive).archiveroot
     filename = os.path.join(archiveroot, "file")
     write_file(filename, "contents")
     self.assertIsNone(self.archive.signing_key)
     run_parts_fixture = self.useFixture(
         MonkeyPatch("lp.archivepublisher.archivesigningkey.run_parts",
                     FakeMethod()))
     custom_processor = CustomUpload()
     custom_processor.sign(self.archive, "suite", filename)
     args, kwargs = run_parts_fixture.new_value.calls[0]
     self.assertEqual((self.distro.name, "sign.d"), args)
     self.assertThat(
         kwargs["env"],
         MatchesDict({
             "ARCHIVEROOT": Equals(archiveroot),
             "INPUT_PATH": Equals(filename),
             "OUTPUT_PATH": Equals("%s.gpg" % filename),
             "MODE": Equals("detached"),
             "DISTRIBUTION": Equals(self.distro.name),
             "SUITE": Equals("suite"),
         }))
Exemplo n.º 3
0
 def test_sign_without_signing_key(self):
     filename = os.path.join(getPubConfig(self.archive).archiveroot, "file")
     self.assertIsNone(self.archive.signing_key)
     custom_processor = CustomUpload()
     custom_processor.sign(self.archive, "suite", filename)
     self.assertThat("%s.gpg" % filename, Not(PathExists()))