← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~andersson123/autopkgtest-cloud:fix_allowed_teams into autopkgtest-cloud:master

 

Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:fix_allowed_teams into autopkgtest-cloud:master.

Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)

For more details, see:
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/447413
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:fix_allowed_teams into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/webcontrol/request/submit.py b/charms/focal/autopkgtest-web/webcontrol/request/submit.py
index 04d7f61..5b3f91e 100644
--- a/charms/focal/autopkgtest-web/webcontrol/request/submit.py
+++ b/charms/focal/autopkgtest-web/webcontrol/request/submit.py
@@ -462,12 +462,24 @@ class Submit:
         return code >= 200 and code < 300
 
     # pylint: disable=dangerous-default-value
-    def in_allowed_team(self, person, package=[], teams=[]):
+    # Need to amend this function to either use the LP api
+    # or to check teams for members recursively.
+    # First check to see if NOT using the LP api was a design choice
+    # or a misstep. Then implement
+    def in_allowed_team(self, person, package=[], teams=[], depth=0):
         """Check if person is in ALLOWED_TEAMS"""
 
         for team in teams or ALLOWED_TEAMS:
             (_, response) = self.lp_request("~%s/participants" % team, {})
             for e in response.get("entries", []):
+                if "Canonical" in e and depth < 1:
+                    list_team = [e]
+                    return self.in_allowed_team(
+                        person=person,
+                        package=package,
+                        teams=list_team,
+                        depth=(depth + 1),
+                    )
                 if e.get("name") == person:
                     return True
         return False

Follow ups