public void MessageRegexMatchFilterConstructorTest() { MessageRegexMatchFilter target = new MessageRegexMatchFilter(); Assert.IsNotNull(target); Assert.IsInstanceOfType(target, typeof(MessageRegexMatchFilter)); }
public void patternTest() { MessageRegexMatchFilter target = new MessageRegexMatchFilter(); // TODO: Eseguire l'inizializzazione a un valore appropriato string expected = string.Empty; // TODO: Eseguire l'inizializzazione a un valore appropriato string actual; target.pattern = expected; actual = target.pattern; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verificare la correttezza del metodo di test."); }
public void IsMatchTest() { //Simply opposite to RegexMatchFilter { MessageRegexMatchFilter target = new MessageRegexMatchFilter { pattern = "FFDA" }; SyslogMessage message = new SyslogMessage(DateTime.Now, "logbus.dis.unina.it", SyslogFacility.Local6, SyslogSeverity.Info, "FFDA SST"); bool expected = false; bool actual; actual = target.IsMatch(message); Assert.AreEqual(expected, actual); } { MessageRegexMatchFilter target = new MessageRegexMatchFilter { pattern = @"^FFDA (SST|SEN|BIND|COA|EIS|EIE|RIS|RIE)" }; SyslogMessage message = new SyslogMessage(DateTime.Now, "logbus.dis.unina.it", SyslogFacility.Local6, SyslogSeverity.Info, "This is FFDA SST"); bool expected = true; bool actual; actual = target.IsMatch(message); Assert.AreEqual(expected, actual); } { MessageRegexMatchFilter target = new MessageRegexMatchFilter { pattern = @"^FFDA (SST|SEN|BIND|COA|EIS|EIE|RIS|RIE)" }; SyslogMessage message = new SyslogMessage(DateTime.Now, "logbus.dis.unina.it", SyslogFacility.Local6, SyslogSeverity.Info, "FFDA EIS 105995"); bool expected = false; bool actual; actual = target.IsMatch(message); Assert.AreEqual(expected, actual); } }
public void filterTest() { OrFilter target = new OrFilter(); FilterBase f1 = new TrueFilter(), f2 = new NotFilter { filter = new FalseFilter() }, f3 = new MessageRegexMatchFilter { pattern = "FFDA" }, f4 = new FacilityEqualsFilter { facility = SyslogFacility.Security }; target.filter = new FilterBase[] { f1, f2, f3, f4 }; Assert.AreEqual(target.filter[0], f1); Assert.IsInstanceOfType(target.filter[1], typeof(NotFilter)); Assert.IsInstanceOfType(target.filter[3], typeof(FacilityEqualsFilter)); Assert.AreEqual(((FacilityEqualsFilter)target.filter[3]).facility, SyslogFacility.Security); }
public void IsMatchTest() { { FilterBase f1 = new FacilityEqualsFilter { facility = SyslogFacility.Ftp }, f2 = new MessageRegexMatchFilter { pattern = "^FFDA" }; OrFilter target = new OrFilter(); target.filter = new FilterBase[] { f1, f2 }; SyslogMessage message = new SyslogMessage { Facility = SyslogFacility.Internally, Severity = SyslogSeverity.Error, Text = "FFDA WOW!" }; bool expected = true; bool actual; actual = target.IsMatch(message); Assert.AreEqual(expected, actual); } { FilterBase f1 = new FacilityEqualsFilter { facility = SyslogFacility.Ftp }, f2 = new MessageRegexMatchFilter { pattern = "^FFDA" }; OrFilter target = new OrFilter(); target.filter = new FilterBase[] { f1, f2 }; SyslogMessage message = new SyslogMessage { Facility = SyslogFacility.Ftp, Severity = SyslogSeverity.Error, Text = "Nobody!" }; bool expected = true; bool actual; actual = target.IsMatch(message); Assert.AreEqual(expected, actual); } { string msg = @"<34>1 2003-10-11T22:14:15.003Z mymachine.example.com su - ID47 - ’su root’ failed for lonvick on /dev/pts/8"; FilterBase f1 = new FacilityEqualsFilter { facility = SyslogFacility.Security }, f2 = new MessageRegexMatchFilter { //Ok, that should be the real UNIX user pattern but let's assume only letters and numbers here :) pattern = "’su root’ failed for [a-zA-Z0-9]" }, f3 = new SeverityFilter { comparison = ComparisonOperator.neq, severity = SyslogSeverity.Emergency }; OrFilter target = new OrFilter(); target.filter = new FilterBase[] { f1, f2, f3 }; SyslogMessage message = SyslogMessage.Parse(msg); bool expected = true; bool actual; actual = target.IsMatch(message); Assert.AreEqual(expected, actual); } }