Skip to content

Commit

Permalink
Reserve the default ping name
Browse files Browse the repository at this point in the history
It can't be used as a ping name, but it can be used in `send_in_pings`.
  • Loading branch information
badboy committed Aug 19, 2021
1 parent 1c66cb2 commit 0da9796
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion glean_parser/pings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 12 additions & 10 deletions tests/test_pings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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():
Expand Down

0 comments on commit 0da9796

Please sign in to comment.