diff --git a/britney2/policies/cloud.py b/britney2/policies/cloud.py index 3fcc123..6e1cc06 100644 --- a/britney2/policies/cloud.py +++ b/britney2/policies/cloud.py @@ -69,7 +69,7 @@ class CloudPolicy(BasePolicy): self.failure_emails = getattr(self.options, "cloud_failure_emails", self.DEFAULT_EMAILS) self.error_emails = getattr(self.options, "cloud_error_emails", self.DEFAULT_EMAILS) - adt_ppas = getattr(self.options, "adt_ppas", []) + adt_ppas = getattr(self.options, "adt_ppas", "").split() ppas = self._parse_ppas(adt_ppas) if len(ppas) == 0: @@ -402,13 +402,16 @@ class CloudPolicy(BasePolicy): def _parse_ppas(self, ppas): """Parse PPA list to store in format expected by cloud tests - Since currently only private PPAs in Britney are provided with fingerprints we will - only use those. + Only supports PPAs provided with a fingerprint Britney private PPA format: 'user:token@team/name:fingerprint' + Britney public PPA format: + 'team/name:fingerprint' Cloud private PPA format: 'https://user:token@private-ppa.launchpadcontent.net/team/name/ubuntu=fingerprint + Cloud public PPA format: + 'https://ppa.launchpadcontent.net/team/name/ubuntu=fingerprint :param ppas List of PPAs in Britney approved format :return A list of PPAs in valid cloud test format. Can return an empty list if none found. @@ -425,6 +428,15 @@ class CloudPolicy(BasePolicy): match.group("auth"), match.group("name"), match.group("fingerprint") ) cloud_ppas.append(formatted_ppa) + else: + match = re.match("^(?P.+):(?P.+$)", ppa) + if not match: + raise RuntimeError('Public PPA %s not following required format (team/name:fingerprint)', ppa) + + formatted_ppa = "https://ppa.launchpadcontent.net/{}/ubuntu={}".format( + match.group("name"), match.group("fingerprint") + ) + cloud_ppas.append(formatted_ppa) return cloud_ppas diff --git a/tests/test_cloud.py b/tests/test_cloud.py index 30363bf..bbd8595 100644 --- a/tests/test_cloud.py +++ b/tests/test_cloud.py @@ -201,11 +201,12 @@ class T(unittest.TestCase): tests. """ input_ppas = [ - "deadsnakes/ppa", + "deadsnakes/ppa:fingerprint", "user:token@team/name:fingerprint" ] expected_ppas = [ + "https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu=fingerprint", "https://user:token@private-ppa.launchpadcontent.net/team/name/ubuntu=fingerprint" ] @@ -214,6 +215,10 @@ class T(unittest.TestCase): def test_errors_raised_if_invalid_ppa_input(self): """Test that error are raised if input PPAs don't match expected format""" + self.assertRaises( + RuntimeError, self.policy._parse_ppas, ["team/name"] + ) + self.assertRaises( RuntimeError, self.policy._parse_ppas, ["user:token@team/name"] )