← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~ines-almeida/launchpad:add-ui-to-update-fetch-service-policy into launchpad:master

 

Ines Almeida has proposed merging ~ines-almeida/launchpad:add-ui-to-update-fetch-service-policy into launchpad:master.

Commit message:
Add fetch_service_policy field to snap admin UI

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/475128

Small change to have `fetch_service_policy` show up in the UI for snaps.
Rocks and crafts don't currently have this UI.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~ines-almeida/launchpad:add-ui-to-update-fetch-service-policy into launchpad:master.
diff --git a/lib/lp/snappy/browser/snap.py b/lib/lp/snappy/browser/snap.py
index dc4d330..572b38b 100644
--- a/lib/lp/snappy/browser/snap.py
+++ b/lib/lp/snappy/browser/snap.py
@@ -527,6 +527,7 @@ class ISnapEditSchema(Interface):
             "store_upload",
             "pro_enable",
             "use_fetch_service",
+            "fetch_service_policy",
         ],
     )
 
@@ -927,6 +928,7 @@ class SnapAdminView(BaseSnapEditView):
         return "Administer %s snap package" % self.context.name
 
     page_title = "Administer"
+    fetch_service_policy_widget = LaunchpadDropdownWidget
 
     # XXX pappacena 2021-02-19: Once we have the whole privacy work in
     # place, we should move "project" and "information_type" from +admin
@@ -942,7 +944,7 @@ class SnapAdminView(BaseSnapEditView):
         ]
 
         if getFeatureFlag(SNAP_USE_FETCH_SERVICE_FEATURE_FLAG):
-            fields.append("use_fetch_service")
+            fields.extend(["use_fetch_service", "fetch_service_policy"])
 
         return fields
 
diff --git a/lib/lp/snappy/browser/tests/test_snap.py b/lib/lp/snappy/browser/tests/test_snap.py
index 819d770..e450c5b 100644
--- a/lib/lp/snappy/browser/tests/test_snap.py
+++ b/lib/lp/snappy/browser/tests/test_snap.py
@@ -34,6 +34,7 @@ from lp.app.interfaces.launchpad import ILaunchpadCelebrities
 from lp.app.widgets.tests.test_snapbuildchannels import (
     TestSnapBuildChannelsWidget,
 )
+from lp.buildmaster.builderproxy import FetchServicePolicy
 from lp.buildmaster.enums import BuildStatus
 from lp.buildmaster.interfaces.processor import IProcessorSet
 from lp.code.errors import BranchHostingFault, GitRepositoryScanFault
@@ -840,11 +841,13 @@ class TestSnapAdminView(BaseTestSnapView):
         self.assertTrue(snap.allow_internet)
         self.assertFalse(snap.pro_enable)
         self.assertFalse(snap.use_fetch_service)
+        self.assertEqual(FetchServicePolicy.STRICT, snap.fetch_service_policy)
 
         self.factory.makeAccessPolicy(
             pillar=project, type=InformationType.PRIVATESECURITY
         )
         private = InformationType.PRIVATESECURITY.name
+        permissive = FetchServicePolicy.PERMISSIVE.name
         browser = self.getViewBrowser(snap, user=admin)
         browser.getLink("Administer snap package").click()
         browser.getControl(name="field.project").value = "my-project"
@@ -853,6 +856,9 @@ class TestSnapAdminView(BaseTestSnapView):
         browser.getControl("Allow external network access").selected = False
         browser.getControl("Enable Ubuntu Pro").selected = True
         browser.getControl("Use fetch service").selected = True
+        browser.getControl(name="field.fetch_service_policy").value = (
+            permissive
+        )
         browser.getControl("Update snap package").click()
 
         # XXX ines-almeida 2024-03-11: Browser tests work oddly with fixtures.
@@ -868,6 +874,9 @@ class TestSnapAdminView(BaseTestSnapView):
         self.assertFalse(snap.allow_internet)
         self.assertTrue(snap.pro_enable)
         self.assertTrue(snap.use_fetch_service)
+        self.assertEqual(
+            FetchServicePolicy.PERMISSIVE, snap.fetch_service_policy
+        )
 
     def test_admin_use_fetch_service_feature_flag(self):
         admin = self.factory.makePerson(