truncate certain event fields when they are overly long

see: https://github.com/ansible/tower/issues/1775
This commit is contained in:
Ryan Petrello
2018-05-14 13:59:44 -04:00
parent 0f98ed5046
commit bb3b19e174
2 changed files with 39 additions and 14 deletions
+15
View File
@@ -44,3 +44,18 @@ def test_playbook_event_strip_invalid_keys(job_identifier, cls):
'extra_key': 'extra_value'
})
manager.create.assert_called_with(**{job_identifier: 123})
@pytest.mark.parametrize('field', [
'play', 'role', 'task', 'playbook'
])
def test_really_long_event_fields(field):
with mock.patch.object(JobEvent, 'objects') as manager:
JobEvent.create_from_data(**{
'job_id': 123,
field: 'X' * 4096
})
manager.create.assert_called_with(**{
'job_id': 123,
field: 'X' * 1021 + '...'
})