← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~vaishnavi-asawale/launchpad:fetch-service-rockcraft into launchpad:master

 

Vaishnavi Asawale has proposed merging ~vaishnavi-asawale/launchpad:fetch-service-rockcraft into launchpad:master.

Commit message:
Enable the 'use_fetch_service' option to everyone for rockcraft builds via the API

Previously, the fetch service was only enabled for privileged users (the Golem). Now,
it is available to everyone, in strict and permissive mode.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~vaishnavi-asawale/launchpad/+git/launchpad/+merge/491157
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~vaishnavi-asawale/launchpad:fetch-service-rockcraft into launchpad:master.
diff --git a/lib/lp/rocks/interfaces/rockrecipe.py b/lib/lp/rocks/interfaces/rockrecipe.py
index 786b4a0..63d6f6e 100644
--- a/lib/lp/rocks/interfaces/rockrecipe.py
+++ b/lib/lp/rocks/interfaces/rockrecipe.py
@@ -726,22 +726,6 @@ class IRockRecipeEditableAttributes(Interface):
         )
     )
 
-
-class IRockRecipeAdminAttributes(Interface):
-    """`IRockRecipe` attributes that can be edited by admins.
-
-    These attributes need launchpad.View to see, and launchpad.Admin to change.
-    """
-
-    require_virtualized = exported(
-        Bool(
-            title=_("Require virtualized builders"),
-            required=True,
-            readonly=False,
-            description=_("Only build this rock recipe on virtual builders."),
-        )
-    )
-
     use_fetch_service = exported(
         Bool(
             title=_("Use fetch service"),
@@ -769,6 +753,22 @@ class IRockRecipeAdminAttributes(Interface):
     )
 
 
+class IRockRecipeAdminAttributes(Interface):
+    """`IRockRecipe` attributes that can be edited by admins.
+
+    These attributes need launchpad.View to see, and launchpad.Admin to change.
+    """
+
+    require_virtualized = exported(
+        Bool(
+            title=_("Require virtualized builders"),
+            required=True,
+            readonly=False,
+            description=_("Only build this rock recipe on virtual builders."),
+        )
+    )
+
+
 # XXX jugmac00 2024-09-16 https://bugs.launchpad.net/lazr.restful/+bug/760849:
 # "beta" is a lie to get WADL generation working.
 # Individual attributes must set their version to "devel".
@@ -810,6 +810,8 @@ class IRockRecipeSet(Interface):
             "store_upload",
             "store_name",
             "store_channels",
+            "use_fetch_service",
+            "fetch_service_policy",
         ],
     )
     @operation_for_version("devel")
diff --git a/lib/lp/rocks/tests/test_rockrecipe.py b/lib/lp/rocks/tests/test_rockrecipe.py
index 6fb1b7a..dc1393a 100644
--- a/lib/lp/rocks/tests/test_rockrecipe.py
+++ b/lib/lp/rocks/tests/test_rockrecipe.py
@@ -1398,8 +1398,6 @@ class TestRockRecipeSet(TestCaseWithFactory):
 
         admin_fields = {
             "require_virtualized": True,
-            "use_fetch_service": True,
-            "fetch_service_policy": FetchServicePolicy.PERMISSIVE,
         }
 
         for field_name, field_value in admin_fields.items():
@@ -1415,8 +1413,6 @@ class TestRockRecipeSet(TestCaseWithFactory):
         person = self.factory.makePerson()
         admin_fields = {
             "require_virtualized": True,
-            "use_fetch_service": True,
-            "fetch_service_policy": FetchServicePolicy.PERMISSIVE,
         }
 
         for field_name, field_value in admin_fields.items():
@@ -1430,6 +1426,27 @@ class TestRockRecipeSet(TestCaseWithFactory):
                     field_value,
                 )
 
+    def test_use_fetch_service(self):
+        [ref] = self.factory.makeGitRefs()
+        rock = self.factory.makeRockRecipe(
+            git_ref=ref, use_fetch_service=False
+        )
+        self.assertEqual(False, rock.use_fetch_service)
+        self.assertEqual(FetchServicePolicy.STRICT, rock.fetch_service_policy)
+        with person_logged_in(rock.owner):
+            rock.use_fetch_service = True
+            rock.fetch_service_policy = FetchServicePolicy.PERMISSIVE
+            self.assertEqual(True, rock.use_fetch_service)
+            self.assertEqual(
+                FetchServicePolicy.PERMISSIVE, rock.fetch_service_policy
+            )
+
+    def test_use_fetch_service_not_passed(self):
+        [ref] = self.factory.makeGitRefs()
+        rock = self.factory.makeRockRecipe(git_ref=ref)
+        self.assertEqual(False, rock.use_fetch_service)
+        self.assertEqual(FetchServicePolicy.STRICT, rock.fetch_service_policy)
+
 
 class TestRockRecipeWebservice(TestCaseWithFactory):