← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:publish-artifactory-without-signing-keys into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:publish-artifactory-without-signing-keys into launchpad:master.

Commit message:
Don't require local key generation before publishing to Artifactory

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/424450

At some point we might want to come up with something that generates local keys and pushes them to Artifactory for it to use, but nothing's set up to do that at the moment and we don't want to block on it.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:publish-artifactory-without-signing-keys into launchpad:master.
diff --git a/lib/lp/archivepublisher/tests/test_publishdistro.py b/lib/lp/archivepublisher/tests/test_publishdistro.py
index 5d833ed..377c824 100644
--- a/lib/lp/archivepublisher/tests/test_publishdistro.py
+++ b/lib/lp/archivepublisher/tests/test_publishdistro.py
@@ -29,6 +29,9 @@ from lp.archivepublisher.interfaces.archivegpgsigningkey import (
 from lp.archivepublisher.interfaces.publisherconfig import IPublisherConfigSet
 from lp.archivepublisher.publishing import Publisher
 from lp.archivepublisher.scripts.publishdistro import PublishDistro
+from lp.archivepublisher.tests.artifactory_fixture import (
+    FakeArtifactoryFixture,
+    )
 from lp.registry.interfaces.distribution import IDistributionSet
 from lp.registry.interfaces.person import IPersonSet
 from lp.registry.interfaces.pocket import PackagePublishingPocket
@@ -42,7 +45,10 @@ from lp.services.scripts.base import LaunchpadScriptFailure
 from lp.soyuz.enums import (
     ArchivePublishingMethod,
     ArchivePurpose,
+    ArchiveRepositoryFormat,
     ArchiveStatus,
+    BinaryPackageFileType,
+    BinaryPackageFormat,
     PackagePublishingStatus,
     )
 from lp.soyuz.interfaces.archive import IArchiveSet
@@ -404,6 +410,36 @@ class TestPublishDistro(TestNativePublishingBase):
         pool_path = os.path.join(repo_path, 'pool/main/b/baz/baz_666.dsc')
         self.assertExists(pool_path)
 
+    def testPublishToArtifactory(self):
+        """Publishing to Artifactory doesn't require generated signing keys."""
+        self.setUpRequireSigningKeys()
+        switch_dbuser("launchpad")
+        base_url = "https://foo.example.com/artifactory";
+        self.pushConfig("artifactory", base_url=base_url)
+        archive = self.factory.makeArchive(
+            distribution=self.ubuntutest,
+            publishing_method=ArchivePublishingMethod.ARTIFACTORY,
+            repository_format=ArchiveRepositoryFormat.PYTHON)
+        das = self.ubuntutest.currentseries.architectures[0]
+        self.useFixture(FakeArtifactoryFixture(base_url, archive.name))
+        ci_build = self.factory.makeCIBuild(distro_arch_series=das)
+        bpn = self.factory.makeBinaryPackageName()
+        bpr = self.factory.makeBinaryPackageRelease(
+            binarypackagename=bpn, version="1.0", ci_build=ci_build,
+            binpackageformat=BinaryPackageFormat.WHL)
+        self.factory.makeBinaryPackageFile(
+            binarypackagerelease=bpr, filetype=BinaryPackageFileType.WHL)
+        bpph = self.factory.makeBinaryPackagePublishingHistory(
+            binarypackagerelease=bpr, archive=archive,
+            distroarchseries=das, pocket=PackagePublishingPocket.RELEASE,
+            architecturespecific=True)
+        self.assertEqual(PackagePublishingStatus.PENDING, bpph.status)
+        self.layer.txn.commit()
+
+        self.runPublishDistro(["--ppa"])
+
+        self.assertEqual(PackagePublishingStatus.PUBLISHED, bpph.status)
+
     def testRunWithEmptySuites(self):
         """Try a publish-distro run on empty suites in careful_apt mode
 
diff --git a/lib/lp/soyuz/model/archive.py b/lib/lp/soyuz/model/archive.py
index 76fbadf..c3b6633 100644
--- a/lib/lp/soyuz/model/archive.py
+++ b/lib/lp/soyuz/model/archive.py
@@ -455,6 +455,10 @@ class Archive(SQLBase):
         # The explicit publish flag must be set.
         if not self.publish:
             return False
+        # Archives published via Artifactory don't (currently?) require
+        # local key generation.
+        if self.publishing_method == ArchivePublishingMethod.ARTIFACTORY:
+            return True
         # In production configurations, PPAs and copy archives can only be
         # published once their signing key has been generated.
         return (