← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~twom/launchpad:oci-test-for-none-official-owner into launchpad:master

 

Tom Wardill has proposed merging ~twom/launchpad:oci-test-for-none-official-owner into launchpad:master.

Commit message:
Add test for setting recipe as official while not being owner

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/402183
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:oci-test-for-none-official-owner into launchpad:master.
diff --git a/lib/lp/registry/tests/test_ociproject.py b/lib/lp/registry/tests/test_ociproject.py
index 91bae07..f345d3f 100644
--- a/lib/lp/registry/tests/test_ociproject.py
+++ b/lib/lp/registry/tests/test_ociproject.py
@@ -236,9 +236,13 @@ class TestOCIProjectWebservice(TestCaseWithFactory):
     def setUp(self):
         super(TestOCIProjectWebservice, self).setUp()
         self.person = self.factory.makePerson(displayname="Test Person")
+        self.other_person = self.factory.makePerson()
         self.webservice = webservice_for_person(
             self.person, permission=OAuthPermission.WRITE_PUBLIC,
             default_api_version="devel")
+        self.other_webservice = webservice_for_person(
+            self.other_person, permission=OAuthPermission.WRITE_PUBLIC,
+            default_api_version="devel")
         self.useFixture(FeatureFixture({OCI_PROJECT_ALLOW_CREATE: ''}))
 
     def getAbsoluteURL(self, target):
@@ -426,6 +430,26 @@ class TestOCIProjectWebservice(TestCaseWithFactory):
             b"The given recipe is invalid for this OCI project.",
             resp.body)
 
+    def test_set_official_recipe_via_webservice_not_owner(self):
+        self.useFixture(FeatureFixture({
+            OCI_PROJECT_ALLOW_CREATE: "on",
+            OCI_RECIPE_ALLOW_CREATE: "on"}))
+        with person_logged_in(self.person):
+            distro = self.factory.makeDistribution(owner=self.person)
+            oci_project = self.factory.makeOCIProject(pillar=distro)
+            other_project = self.factory.makeOCIProject()
+            oci_recipe = self.factory.makeOCIRecipe(
+                oci_project=other_project)
+            oci_recipe_url = api_url(oci_recipe)
+            url = api_url(oci_project)
+
+        obj = {"recipe": oci_recipe_url, "status": True}
+        resp = self.other_webservice.named_post(
+            url, "setOfficialRecipeStatus", **obj)
+
+        self.assertEqual(401, resp.status)
+        self.assertIn(b"launchpad.Edit", resp.body)
+
 
 class TestOCIProjectVocabulary(TestCaseWithFactory):
     layer = DatabaseFunctionalLayer