MCPcopy Index your code
hub / github.com/apache/casbin / TestSyntaxMatcher

Function TestSyntaxMatcher

syntax_test.go:25–34  ·  view source on GitHub ↗

TestSyntaxMatcher tests that patterns like "p." inside quoted strings are not incorrectly escaped by EscapeAssertion. This addresses the bug where matchers containing strings like "a.p.p.l.e" would have the ".p." pattern incorrectly replaced with "_p_".

(t *testing.T)

Source from the content-addressed store, hash-verified

23// This addresses the bug where matchers containing strings like "a.p.p.l.e"
24// would have the ".p." pattern incorrectly replaced with "_p_".
25func TestSyntaxMatcher(t *testing.T) {
26 e, err := NewEnforcer("examples/syntax_matcher_model.conf")
27 if err != nil {
28 t.Fatalf("Error: %v\n", err)
29 }
30 // The matcher in syntax_matcher_model.conf is: m = r.sub == "a.p.p.l.e"
31 // This should match when r.sub is exactly "a.p.p.l.e"
32 testEnforce(t, e, "a.p.p.l.e", "file", "read", true)
33 testEnforce(t, e, "other", "file", "read", false)
34}

Callers

nothing calls this directly

Calls 2

NewEnforcerFunction · 0.85
testEnforceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…