зеркало из https://github.com/mozilla/onyx.git
Extract action field from ping-centre ping
This commit is contained in:
Родитель
40e9d6cd45
Коммит
d8d69b887d
|
@ -172,6 +172,7 @@ def handle_ping_centre_ping(ping_type, log_name):
|
|||
client_payload_raw = request.get_data(cache=False)
|
||||
client_payload = ujson.decode(client_payload_raw)
|
||||
assert 'topic' in client_payload # treat it as malformed payload if "topic" is missing
|
||||
action = client_payload.get("action", "ping_centre")
|
||||
|
||||
ip_addr = request.headers.get('X-Forwarded-For')
|
||||
if ip_addr is None:
|
||||
|
@ -191,7 +192,7 @@ def handle_ping_centre_ping(ping_type, log_name):
|
|||
return Response('', content_type='application/json; charset=utf-8',
|
||||
status=400)
|
||||
|
||||
env.log_dict(name=log_name, action="ping_centre", message=client_payload)
|
||||
env.log_dict(name=log_name, action=action, message=client_payload)
|
||||
|
||||
env.statsd.incr("{0}".format(ping_type))
|
||||
return Response('', content_type='application/json; charset=utf-8',
|
||||
|
|
|
@ -293,9 +293,14 @@ class TestPingCentrePing(BaseTestCase):
|
|||
assert_equals(response.content_length, 0)
|
||||
|
||||
def test_payload_meta(self):
|
||||
payload = {
|
||||
"data": "test",
|
||||
"action": "ping_centre_action",
|
||||
"topic": "activity_stream_mobile_session"
|
||||
}
|
||||
response = self.client.post(url_for('v3_links.ping_centre'),
|
||||
content_type='application/json',
|
||||
headers=[("User-Agent", "TestClient")],
|
||||
data=json.dumps({"data": "test", "topic": "activity_stream_mobile_session"}))
|
||||
data=json.dumps(payload))
|
||||
assert_equals(response.status_code, 200)
|
||||
assert_equals(response.content_length, 0)
|
||||
|
|
Загрузка…
Ссылка в новой задаче