cta-wave / WMAS

Test suite for the Web Media API Snapshot Specification
Other
18 stars 9 forks source link

Invalid data in REST requests can break test runner, requiring restart #71

Closed dantallis-edt closed 2 years ago

dantallis-edt commented 2 years ago

I've been using the REST API to drive the 2019 hosted test runner.

I appear to have inadvertently broken it -- very sorry! I believe it needs to be restarted.

The problem is there is no validation of the "expiration_date" field when trying to create a session through the REST API, and I was sending an ISO-format string instead of an int. This appears to not only fail to create a new session but also to prevent many other subsequent uses of the server, including unrelated sessions, because of other locations where the code assumes an int but is now getting a str.

A possible fix is:

Index: tools/wave/network/api/sessions_api_handler.py
===================================================================
--- tools/wave/network/api/sessions_api_handler.py      (revision 82358)
+++ tools/wave/network/api/sessions_api_handler.py      (working copy)
@@ -50,7 +50,12 @@
                 labels = config["labels"]
             expiration_date = None
             if "expiration_date" in config:
-                expiration_date = config["expiration_date"]
+                try:
+                    expiration_date = int(config["expiration_date"])
+                except ValueError as exc:
+                    msg = "expiration_date must be an int, got: {}".format(
+                        config["expiration_date"])
+                    raise InvalidDataException(msg) from exc
             type = None
             if "type" in config:
                 type = config["type"]

I am not quite set up to do this as a pull request -- will do that shortly.

louaybassbouss commented 2 years ago

@dantallis-edt the issue should be fixed now. please check and close this issue if it works for you.