diff --git a/CHANGELOG.md b/CHANGELOG.md index a25d1a750..6b05a9ab3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - Add support for Text metric type ([#374](https://github.com/mozilla/glean_parser/pull/374)) +- Reserve the `default` ping name. It can't be used as a ping name, but it can be used in `send_in_pings` ([#376](https://github.com/mozilla/glean_parser/pull/376)) ## 3.8.0 (2021-08-18) diff --git a/glean_parser/pings.py b/glean_parser/pings.py index 51fe5fb78..7e88d1b8f 100644 --- a/glean_parser/pings.py +++ b/glean_parser/pings.py @@ -14,7 +14,7 @@ from . import util -RESERVED_PING_NAMES = ["baseline", "metrics", "events", "deletion-request"] +RESERVED_PING_NAMES = ["baseline", "metrics", "events", "deletion-request", "default"] class Ping: diff --git a/tests/test_pings.py b/tests/test_pings.py index 49bb42717..e974cc3a1 100644 --- a/tests/test_pings.py +++ b/tests/test_pings.py @@ -3,7 +3,7 @@ # Any copyright is dedicated to the Public Domain. # http://creativecommons.org/publicdomain/zero/1.0/ -from glean_parser import parser +from glean_parser import parser, pings import util @@ -12,17 +12,19 @@ def test_reserved_ping_name(): """ Make sure external users can't use a reserved ping name. """ - content = {"baseline": {"include_client_id": True}} - util.add_required_ping(content) - errors = list(parser._instantiate_pings({}, {}, content, "", {})) - assert len(errors) == 1 - assert "Ping uses a reserved name" in errors[0] + for ping in pings.RESERVED_PING_NAMES: + content = {ping: {"include_client_id": True}} - errors = list( - parser._instantiate_pings({}, {}, content, "", {"allow_reserved": True}) - ) - assert len(errors) == 0 + util.add_required_ping(content) + errors = list(parser._instantiate_pings({}, {}, content, "", {})) + assert len(errors) == 1, f"Ping '{ping}' should not be allowed" + assert "Ping uses a reserved name" in errors[0] + + errors = list( + parser._instantiate_pings({}, {}, content, "", {"allow_reserved": True}) + ) + assert len(errors) == 0 def test_reserved_metrics_category():