public void TestInfixEmptyMatcher_ignoreCase() { var matcher = WildcardMatcher.ValueOf("**"); matcher.Matches("").Should().BeTrue(); matcher.Matches("foo").Should().BeTrue(); }
public void SimpleTestCaseSensitive() { var matcher = WildcardMatcher.ValueOf("(?-i)Foo"); matcher.Matches("Foo").Should().BeTrue(); matcher.Matches("foo").Should().BeFalse(); }
public void TestMatchesInfix_caseSensitive() { var matcher = WildcardMatcher.ValueOf("(?-i)*foo*"); matcher.Matches("foo").Should().BeTrue(); matcher.Matches("FOO").Should().BeFalse(); }
public void TestMatchesEquals() { var matcher = WildcardMatcher.ValueOf("foo"); matcher.Matches("foo").Should().BeTrue(); matcher.Matches("foobar").Should().BeFalse(); matcher.Matches("bar").Should().BeFalse(); matcher.Matches("barfoo").Should().BeFalse(); }
public void TestMatchesStartsWith_ignoreCase() { var matcher = WildcardMatcher.ValueOf("foo*"); matcher.Matches("foo").Should().BeTrue(); matcher.Matches("foobar").Should().BeTrue(); matcher.Matches("bar").Should().BeFalse(); matcher.Matches("barfoo").Should().BeFalse(); }
public void TestMatchesNoWildcard_ignoreCase() { var matcher = WildcardMatcher.ValueOf("foo"); matcher.Matches("FO", "O").Should().BeTrue(); matcher.Matches("FOO").Should().BeTrue(); matcher.Matches("foO", "Bar").Should().BeFalse(); matcher.Matches("foobar").Should().BeFalse(); }
public void TestMatchesEndsWith_ignoreCase() { var matcher = WildcardMatcher.ValueOf("*foo"); matcher.Matches("fOo").Should().BeTrue(); matcher.Matches("foobar").Should().BeFalse(); matcher.Matches("bar").Should().BeFalse(); matcher.Matches("baRFoo").Should().BeTrue(); }
public void TestMatchesEquals_ignoreCase() { var matcher = WildcardMatcher.ValueOf("foo"); matcher.Matches("fOo").Should().BeTrue(); matcher.Matches("foOBar").Should().BeFalse(); matcher.Matches("BAR").Should().BeFalse(); matcher.Matches("barfoo").Should().BeFalse(); }
public void TestMatchesInfix_ignoreCase() { var matcher = WildcardMatcher.ValueOf("*foo*"); matcher.Matches("FOO").Should().BeTrue(); matcher.Matches("foOBar").Should().BeTrue(); matcher.Matches("BAR").Should().BeFalse(); matcher.Matches("baRFOo").Should().BeTrue(); matcher.Matches("BARFOOBAZ").Should().BeTrue(); }
public void TestMatchesInfixPartitionedString_allocationFree() { var matcher = WildcardMatcher.ValueOf("*foo*"); // no allocations necessary matcher.Matches("foo", "bar").Should().BeTrue(); matcher.Matches("bar", "foo").Should().BeTrue(); matcher.Matches("barfoo", "baz").Should().BeTrue(); matcher.Matches("ba", "rfoo").Should().BeTrue(); }
public void TestCompoundWildcardMatcher() { var matcher = WildcardMatcher.ValueOf("*foo*foo*"); matcher.Matches("foofoo").Should().BeTrue(); matcher.Matches("foo/bar/foo").Should().BeTrue(); matcher.Matches("/foo/bar/foo/bar").Should().BeTrue(); matcher.Matches("foo").Should().BeFalse(); }
public void TestMatchesNoWildcard() { var matcher = WildcardMatcher.ValueOf("foo"); // requires concatenating the string matcher.Matches("fo", "o").Should().BeTrue(); matcher.Matches("foo").Should().BeTrue(); matcher.Matches("foo", "bar").Should().BeFalse(); matcher.Matches("foobar").Should().BeFalse(); }
public void TestMatchesInfixPartitionedString_notAllocationFree() { var matcher = WildcardMatcher.ValueOf("*foo*"); // requires concatenating the string matcher.Matches("fo", "o").Should().BeTrue(); matcher.Matches("fo", null).Should().BeFalse(); matcher.Matches("barfo", "obaz").Should().BeTrue(); matcher.Matches("bar", "baz").Should().BeFalse(); }
public void TestMatchesPartitionedStringEndsWith() { var matcher = WildcardMatcher.ValueOf("*/bar/baz"); matcher.Matches("/foo/bar/baz", "").Should().BeTrue(); matcher.Matches("", "/foo/bar/baz").Should().BeTrue(); matcher.Matches("/foo/bar", "/baz").Should().BeTrue(); matcher.Matches("/foo", "/bar/baz").Should().BeTrue(); matcher.Matches("/foo", "/bar/baz").Should().BeTrue(); matcher.Matches("/bar", "/foo/baz").Should().BeFalse(); matcher.Matches("/foo", "/foo/baz").Should().BeFalse(); }
public void TestMatchesPartitionedStringEndsWith_ignoreCase() { var matcher = WildcardMatcher.ValueOf("*/bar/baz"); matcher.Matches("/foO/BAR/Baz", "").Should().BeTrue(); matcher.Matches("", "/foO/Bar/baz").Should().BeTrue(); matcher.Matches("/FOo/bar", "/baz").Should().BeTrue(); matcher.Matches("/foo", "/bar/BAZ").Should().BeTrue(); matcher.Matches("/fOo", "/bAR/baz").Should().BeTrue(); matcher.Matches("/bar", "/foO/baz").Should().BeFalse(); matcher.Matches("/FOo", "/foo/baz").Should().BeFalse(); }
public void TestWildcardInTheMiddle() { var matcher = WildcardMatcher.ValueOf("/foo/*/baz"); matcher.Matches("/foo/*/baz").Should().BeTrue(); matcher.Matches("/foo/bar/baz").Should().BeTrue(); matcher.Matches("/foo/bar", "/baz").Should().BeTrue(); matcher.Matches("/foo/bar/b", "az").Should().BeTrue(); matcher.Matches("/foo/bar", "/boaz").Should().BeFalse(); matcher.Matches("/foo/bar").Should().BeFalse(); }
public void TestNeedleLongerThanHaystack() { WildcardMatcher.ValueOf("*foo").Matches("baz").Should().BeFalse(); WildcardMatcher.ValueOf("*foob").Matches("baz").Should().BeFalse(); WildcardMatcher.ValueOf("*fooba").Matches("baz").Should().BeFalse(); WildcardMatcher.ValueOf("*foobar").Matches("baz").Should().BeFalse(); WildcardMatcher.ValueOf("foo*").Matches("baz").Should().BeFalse(); WildcardMatcher.ValueOf("foob*").Matches("baz").Should().BeFalse(); WildcardMatcher.ValueOf("fooba*").Matches("baz").Should().BeFalse(); WildcardMatcher.ValueOf("foobar*").Matches("baz").Should().BeFalse(); WildcardMatcher.ValueOf("*foobar*").Matches("baz").Should().BeFalse(); }
public void TestMatchesInfixPartitionedString_ignoreCase() { var matcher = WildcardMatcher.ValueOf("*foo*"); // no allocations necessary matcher.Matches("foo", "BAR").Should().BeTrue(); matcher.Matches("BAR", "foo").Should().BeTrue(); matcher.Matches("baRFoo", "baz").Should().BeTrue(); matcher.Matches("bA", "Rfoo").Should().BeTrue(); matcher.Matches("fo", "O").Should().BeTrue(); matcher.Matches("barFO", "obaz").Should().BeTrue(); matcher.Matches("bar", "baz").Should().BeFalse(); }
public void TestMatchBetween() { var matcher = WildcardMatcher.ValueOf("*foo*foo*"); matcher.Matches("foofoo").Should().BeTrue(); matcher.Matches("foofo", "o").Should().BeTrue(); matcher.Matches("foof", "oo").Should().BeTrue(); matcher.Matches("foo", "foo").Should().BeTrue(); matcher.Matches("fo", "ofoo").Should().BeTrue(); matcher.Matches("f", "oofoo").Should().BeTrue(); matcher.Matches("foo/foo/foo/baz").Should().BeTrue(); matcher.Matches("/foo/foo/baz").Should().BeTrue(); matcher.Matches("/foo/foo").Should().BeTrue(); matcher.Matches("foobar").Should().BeFalse(); }
static DefaultValues() { SanitizeFieldNames = new List <WildcardMatcher>(); foreach (var item in new List <string> { "password", "passwd", "pwd", "secret", "*key", "*token*", "*session*", "*credit*", "*card*", "authorization", "set-cookie" }) { SanitizeFieldNames.Add(WildcardMatcher.ValueOf(item)); } TransactionIgnoreUrls = new List <WildcardMatcher>(); foreach (var item in new List <string> { "/VAADIN/*", "/heartbeat*", "/favicon.ico", "*.js", "*.css", "*.jpg", "*.jpeg", "*.png", "*.gif", "*.webp", "*.svg", "*.woff", "*.woff2" }) { TransactionIgnoreUrls.Add(WildcardMatcher.ValueOf(item)); } }
static DefaultValues() { SanitizeFieldNames = new List <WildcardMatcher>(); foreach (var item in new List <string> { "password", "passwd", "pwd", "secret", "*key", "*token*", "*session*", "*credit*", "*card*", "authorization", "set-cookie" }) { SanitizeFieldNames.Add(WildcardMatcher.ValueOf(item)); } }
public void TestMatchAnyStartsWith() { var matcher1 = WildcardMatcher.ValueOf("foo*"); var matcher2 = WildcardMatcher.ValueOf("bar*"); WildcardMatcher.AnyMatch(new List <WildcardMatcher> { matcher1, matcher2 }, "foo").Should().Be(matcher1); WildcardMatcher.AnyMatch(new List <WildcardMatcher> { matcher1, matcher2 }, "bar").Should().Be(matcher2); WildcardMatcher.AnyMatch(new List <WildcardMatcher> { matcher1, matcher2 }, "baz").Should().BeNull(); WildcardMatcher.AnyMatch(new List <WildcardMatcher> { matcher1, matcher2 }, "fo", "o").Should().Be(matcher1); WildcardMatcher.AnyMatch(new List <WildcardMatcher> { matcher1, matcher2 }, "ba", "r").Should().Be(matcher2); WildcardMatcher.AnyMatch(new List <WildcardMatcher> { matcher1, matcher2 }, "ba", "z").Should().BeNull(); }
public void TestComplexExpressions() { WildcardMatcher.ValueOf("/foo/*/baz*").Matches("/foo/a/bar/b/baz").Should().BeTrue(); WildcardMatcher.ValueOf("/foo/*/bar/*/baz").Matches("/foo/a/bar/b/baz").Should().BeTrue(); }