def test_log_audit_with_object_diff(request_context): old = { "a": "b", "b": "c", } new = { "b": "c", } with on_time("2018-04-15 16:50", "CET"): log_audit( object_ref=None, action="bla", message="Message", user_id=UserId("calvin"), diff_text=make_diff_text(old, new), ) store = AuditLogStore(AuditLogStore.make_path()) assert store.read() == [ AuditLogStore.Entry( time=1523811000, object_ref=None, user_id="calvin", action="bla", text="Message", diff_text='Attribute "a" with value "b" removed.', ), ]
def __init__(self): self._options = { key: vs.default_value() for key, vs in self._audit_log_options() } super().__init__() self._store = AuditLogStore(AuditLogStore.make_path()) self._show_details = request.get_integer_input_mandatory( "show_details", 1) == 1
def _migrate_pre_2_0_audit_log(self): old_path = Path(cmk.utils.paths.var_dir, "wato", "log", "audit.log") new_path = Path(cmk.utils.paths.var_dir, "wato", "log", "wato_audit.log") if not old_path.exists(): self._logger.log(VERBOSE, "No audit log present. Skipping.") return if new_path.exists(): self._logger.log(VERBOSE, "New audit log already existing. Skipping.") return store = AuditLogStore(AuditLogStore.make_path()) store.write(list(self._read_pre_2_0_audit_log(old_path))) old_path.unlink()
def test_log_audit_with_html_message(request_context): with on_time("2018-04-15 16:50", "CET"): log_audit( object_ref=None, user_id=UserId("calvin"), action="bla", message=HTML("Message <b>bla</b>"), ) store = AuditLogStore(AuditLogStore.make_path()) assert store.read() == [ AuditLogStore.Entry( time=1523811000, object_ref=None, user_id="calvin", action="bla", text=HTML("Message <b>bla</b>"), diff_text=None, ), ]
def test_log_audit_with_html_message(register_builtin_html): with on_time('2018-04-15 16:50', 'CET'): log_audit( object_ref=None, user_id=UserId('calvin'), action="bla", message=HTML("Message <b>bla</b>"), ) store = AuditLogStore(AuditLogStore.make_path()) assert store.read() == [ AuditLogStore.Entry( time=1523811000, object_ref=None, user_id='calvin', action='bla', text=HTML("Message <b>bla</b>"), diff_text=None, ), ]
def __init__(self): self._options = self._vs_audit_log_options().default_value() super(ModeAuditLog, self).__init__() self._store = AuditLogStore(AuditLogStore.make_path())