canonical-ubuntu-qa team mailing list archive
-
canonical-ubuntu-qa team
-
Mailing list archive
-
Message #00971
[Merge] ~andersson123/autopkgtest-cloud:duplicate_requests into autopkgtest-cloud:master
Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:duplicate_requests 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/446936
--
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:duplicate_requests into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/webcontrol/request/app.py b/charms/focal/autopkgtest-web/webcontrol/request/app.py
index 8654ec2..1882a76 100644
--- a/charms/focal/autopkgtest-web/webcontrol/request/app.py
+++ b/charms/focal/autopkgtest-web/webcontrol/request/app.py
@@ -53,6 +53,13 @@ SUCCESS = """
</dl>
"""
+# Already exists in invalid request function
+# INVALID_REQUEST = """
+# <body>
+# <p>You have submitted an invalid request!</p>
+# </body>
+# """
+
def check_github_sig(request):
"""Validate github signature of request.
@@ -102,6 +109,14 @@ def maybe_escape(value):
return _escape(value) if value else value
+def duplicate_triggers(params):
+ return (
+ True
+ if len(set(params["triggers"])) != len(params["triggers"])
+ else False
+ )
+
+
# Initialize app
PATH = os.path.join(os.path.sep, "run", "autopkgtest_webcontrol")
os.makedirs(PATH, exist_ok=True)
@@ -146,6 +161,9 @@ def index_root():
splitenv += e.split(";")
params["env"] = splitenv
+ if duplicate_triggers(params):
+ return invalid("duplicate triggers in request input.")
+
# request from github?
if b"api.github.com" in request.data:
if not check_github_sig(request):