Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reserve the default ping name #376

Merged
merged 1 commit into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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