Example #1
0
def test_audit_data():
    e = Audit(event='new-message', data='Some data', actor=_ACTOR_NAME, phase=_PHASE_NAME, context=_CONTEXT_NAME,
              hostname=_HOSTNAME)
    e.store()
    assert e.data_source_id
    assert e.host_id
    assert not e.message
Example #2
0
def test_audit_not_saved_message():
    msg = test_message(saved=False)
    e = Audit(event='new-message', message=msg, actor=_ACTOR_NAME, phase=_PHASE_NAME, context=_CONTEXT_NAME,
              hostname=_HOSTNAME)
    e.store()
    assert e.data_source_id
    assert e.host_id
    assert e.message.message_id
    assert e.message.data_source_id == e.data_source_id
    assert e.message.host_id == e.host_id
Example #3
0
 def _process_message(self, message):
     message['event'] = 'new-message'
     message_keys = ('stamp', 'topic', 'actor', 'phase', 'hostname',
                     'context', 'msg_type')
     audit_keys = ('event', 'stamp', 'data', 'actor', 'phase', 'hostname',
                   'context')
     message['msg_type'] = message.pop('type')
     payload = message.pop('message')
     msg = Message(**dict(((k, message[k]) for k in message_keys
                           if k in message)))
     audit = Audit(**dict(((k, message[k]) for k in audit_keys
                           if k in message)))
     audit.message = msg
     audit.message.data = MessageData(data=payload['data'],
                                      hash_id=payload['hash'])
     audit.store()
     return message
Example #4
0
def test_audit_non_string_data():
    e = Audit(event='new-message', data=['Some data'], actor=_ACTOR_NAME, phase=_PHASE_NAME, context=_CONTEXT_NAME,
              hostname=_HOSTNAME)
    e.store()
    assert e.audit_id
    current = e.audit_id
    e.store()
    assert current is e.audit_id
    assert e.data_source_id
    assert e.host_id
    assert not e.message
Example #5
0
 def _do_emit(log_data):
     log_data['data'] = log_data.pop('log', {})
     Audit(**log_data).store()