Drop OwnTracks bad packets (#19161)

This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2018-12-10 12:24:56 +01:00
1 parent fe2d24c240
commit fdea9cb426
2 files changed
+38 -11

No files matched your search

+23 -4
View File
@@ -110,7 +110,7 @@ def test_handle_value_error(mock_client):
@asyncio.coroutine
def test_returns_error_missing_username(mock_client):
def test_returns_error_missing_username(mock_client, caplog):
"""Test that an error is returned when username is missing."""
resp = yield from mock_client.post(
'/api/webhook/owntracks_test',
@@ -120,10 +120,29 @@ def test_returns_error_missing_username(mock_client):
}
)
assert resp.status == 400
# Needs to be 200 or OwnTracks keeps retrying bad packet.
assert resp.status == 200
json = yield from resp.json()
assert json == {'error': 'You need to supply username.'}
assert json == []
assert 'No topic or user found' in caplog.text
@asyncio.coroutine
def test_returns_error_incorrect_json(mock_client, caplog):
"""Test that an error is returned when username is missing."""
resp = yield from mock_client.post(
'/api/webhook/owntracks_test',
data='not json',
headers={
'X-Limit-d': 'Pixel',
}
)
# Needs to be 200 or OwnTracks keeps retrying bad packet.
assert resp.status == 200
json = yield from resp.json()
assert json == []
assert 'invalid JSON' in caplog.text
@asyncio.coroutine