MCPcopy
hub / github.com/apache/casbin / TestInitEmpty

Function TestInitEmpty

enforcer_test.go:414–430  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

412}
413
414func TestInitEmpty(t *testing.T) {
415 e, _ := NewEnforcer()
416
417 m := model.NewModel()
418 m.AddDef("r", "r", "sub, obj, act")
419 m.AddDef("p", "p", "sub, obj, act")
420 m.AddDef("e", "e", "some(where (p.eft == allow))")
421 m.AddDef("m", "m", "r.sub == p.sub && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act)")
422
423 a := fileadapter.NewAdapter("examples/keymatch_policy.csv")
424
425 e.SetModel(m)
426 e.SetAdapter(a)
427 _ = e.LoadPolicy()
428
429 testEnforce(t, e, "alice", "/alice_data/resource1", "GET", true)
430}
431func testEnforceEx(t *testing.T, e *Enforcer, sub, obj, act interface{}, res []string) {
432 t.Helper()
433 _, myRes, _ := e.EnforceEx(sub, obj, act)

Callers

nothing calls this directly

Calls 7

AddDefMethod · 0.95
SetModelMethod · 0.95
SetAdapterMethod · 0.95
LoadPolicyMethod · 0.95
NewModelFunction · 0.92
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…