← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~vaishnavi-asawale/launchpad:fetch_service_sourcecraft into launchpad:master

 

Vaishnavi Asawale has proposed merging ~vaishnavi-asawale/launchpad:fetch_service_sourcecraft into launchpad:master.

Commit message:
Enable the 'use_fetch_service' option to everyone for sourcecraft 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/491037
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~vaishnavi-asawale/launchpad:fetch_service_sourcecraft into launchpad:master.
diff --git a/lib/lp/crafts/interfaces/craftrecipe.py b/lib/lp/crafts/interfaces/craftrecipe.py
index 12c1d85..92cae2a 100644
--- a/lib/lp/crafts/interfaces/craftrecipe.py
+++ b/lib/lp/crafts/interfaces/craftrecipe.py
@@ -720,22 +720,6 @@ class ICraftRecipeEditableAttributes(Interface):
         )
     )
 
-
-class ICraftRecipeAdminAttributes(Interface):
-    """`ICraftRecipe` 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 craft recipe on virtual builders."),
-        )
-    )
-
     use_fetch_service = exported(
         Bool(
             title=_("Use fetch service"),
@@ -763,6 +747,22 @@ class ICraftRecipeAdminAttributes(Interface):
     )
 
 
+class ICraftRecipeAdminAttributes(Interface):
+    """`ICraftRecipe` 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 craft recipe on virtual builders."),
+        )
+    )
+
+
 # XXX ruinedyourlife 2024-10-02
 # https://bugs.launchpad.net/lazr.restful/+bug/760849:
 # "beta" is a lie to get WADL generation working.
@@ -809,6 +809,8 @@ class ICraftRecipeSet(Interface):
             "store_upload",
             "store_name",
             "store_channels",
+            "use_fetch_service",
+            "fetch_service_policy",
         ],
     )
     @operation_for_version("devel")
diff --git a/lib/lp/crafts/tests/test_craftrecipe.py b/lib/lp/crafts/tests/test_craftrecipe.py
index 2dd2e7c..f84b748 100644
--- a/lib/lp/crafts/tests/test_craftrecipe.py
+++ b/lib/lp/crafts/tests/test_craftrecipe.py
@@ -995,8 +995,6 @@ class TestCraftRecipeSet(TestCaseWithFactory):
 
         admin_fields = {
             "require_virtualized": True,
-            "use_fetch_service": True,
-            "fetch_service_policy": FetchServicePolicy.PERMISSIVE,
         }
 
         for field_name, field_value in admin_fields.items():
@@ -1013,8 +1011,6 @@ class TestCraftRecipeSet(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():
@@ -1028,6 +1024,20 @@ class TestCraftRecipeSet(TestCaseWithFactory):
                     field_value,
                 )
 
+    def test_use_fetch_service(self):
+        [ref] = self.factory.makeGitRefs()
+        craft = self.factory.makeCraftRecipe(
+            git_ref=ref, use_fetch_service=False
+        )
+        self.assertEqual(FetchServicePolicy.STRICT, craft.fetch_service_policy)
+        with person_logged_in(craft.owner):
+            craft.use_fetch_service = True
+            craft.fetch_service_policy = FetchServicePolicy.PERMISSIVE
+            self.assertEqual(True, craft.use_fetch_service)
+            self.assertEqual(
+                FetchServicePolicy.PERMISSIVE, craft.fetch_service_policy
+            )
+
 
 class TestCraftRecipeDeleteWithBuilds(TestCaseWithFactory):
 

Follow ups