Skip to content

Commit

Permalink
chore: (syslog source): add source_ip to some syslog tests (vectordot…
Browse files Browse the repository at this point in the history
…dev#17235)

Add source_ip to some syslog tests

Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com>
  • Loading branch information
StephenWakely authored Apr 27, 2023
1 parent 9031d0f commit 29c34c0
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions src/sources/syslog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -829,10 +829,17 @@ mod test {
expected.insert("version", 1);
expected.insert("appname", "root");
expected.insert("procid", 8449);
expected.insert("source_ip", "192.168.0.254");
}

assert_event_data_eq!(
event_from_bytes("host", None, raw.into(), LogNamespace::Legacy).unwrap(),
event_from_bytes(
"host",
Some(Bytes::from("192.168.0.254")),
raw.into(),
LogNamespace::Legacy
)
.unwrap(),
expected
);
}
Expand Down Expand Up @@ -865,17 +872,30 @@ mod test {
expected.insert("version", 1);
expected.insert("appname", "root");
expected.insert("procid", 8449);
expected.insert("source_ip", "192.168.0.254");
}

let event = event_from_bytes("host", None, raw.into(), LogNamespace::Legacy).unwrap();
let event = event_from_bytes(
"host",
Some(Bytes::from("192.168.0.254")),
raw.into(),
LogNamespace::Legacy,
)
.unwrap();
assert_event_data_eq!(event, expected);

let raw = format!(
r#"<13>1 2019-02-13T19:48:34+00:00 74794bfb6795 root 8449 - {} {}"#,
r#"[incorrect x=]"#, msg
);

let event = event_from_bytes("host", None, raw.into(), LogNamespace::Legacy).unwrap();
let event = event_from_bytes(
"host",
Some(Bytes::from("192.168.0.254")),
raw.into(),
LogNamespace::Legacy,
)
.unwrap();
assert_event_data_eq!(event, expected);
}

Expand Down Expand Up @@ -958,7 +978,13 @@ mod test {
fn syslog_ng_default_network() {
let msg = "i am foobar";
let raw = format!(r#"<13>Feb 13 20:07:26 74794bfb6795 root[8539]: {}"#, msg);
let event = event_from_bytes("host", None, raw.into(), LogNamespace::Legacy).unwrap();
let event = event_from_bytes(
"host",
Some(Bytes::from("192.168.0.254")),
raw.into(),
LogNamespace::Legacy,
)
.unwrap();

let mut expected = Event::Log(LogEvent::from(msg));
{
Expand Down Expand Up @@ -986,6 +1012,7 @@ mod test {
expected.insert("facility", "user");
expected.insert("appname", "root");
expected.insert("procid", 8539);
expected.insert("source_ip", "192.168.0.254");
}

assert_event_data_eq!(event, expected);
Expand All @@ -998,7 +1025,13 @@ mod test {
r#"<190>Feb 13 21:31:56 74794bfb6795 liblogging-stdlog: [origin software="rsyslogd" swVersion="8.24.0" x-pid="8979" x-info="http://www.rsyslog.com"] {}"#,
msg
);
let event = event_from_bytes("host", None, raw.into(), LogNamespace::Legacy).unwrap();
let event = event_from_bytes(
"host",
Some(Bytes::from("192.168.0.254")),
raw.into(),
LogNamespace::Legacy,
)
.unwrap();

let mut expected = Event::Log(LogEvent::from(msg));
{
Expand Down Expand Up @@ -1026,6 +1059,7 @@ mod test {
expected.insert("appname", "liblogging-stdlog");
expected.insert("origin.software", "rsyslogd");
expected.insert("origin.swVersion", "8.24.0");
expected.insert("source_ip", "192.168.0.254");
expected.insert(event_path!("origin", "x-pid"), "8979");
expected.insert(event_path!("origin", "x-info"), "http://www.rsyslog.com");
}
Expand Down

0 comments on commit 29c34c0

Please sign in to comment.