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

Function testEnforcePBAC

pbac_test.go:22–32  ·  view source on GitHub ↗

Helper function for PBAC enforcement testing.

(t *testing.T, e *Enforcer, sub interface{}, obj interface{}, act string, res bool)

Source from the content-addressed store, hash-verified

20
21// Helper function for PBAC enforcement testing.
22func testEnforcePBAC(t *testing.T, e *Enforcer, sub interface{}, obj interface{}, act string, res bool) {
23 t.Helper()
24 myRes, err := e.Enforce(sub, obj, act)
25 if err != nil {
26 t.Errorf("Enforce Error: %s", err)
27 return
28 }
29 if myRes != res {
30 t.Errorf("%v, %v, %s: %t, supposed to be %t", sub, obj, act, myRes, res)
31 }
32}
33
34func TestPBACModel(t *testing.T) {
35 e, _ := NewEnforcer("examples/pbac_model.conf", "examples/pbac_policy.csv")

Callers 1

TestPBACModelFunction · 0.85

Calls 1

EnforceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…