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

Function TestGetAndSetAdapterInMem

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

Source from the content-addressed store, hash-verified

385}
386
387func TestGetAndSetAdapterInMem(t *testing.T) {
388 e, _ := NewEnforcer("examples/basic_model.conf", "examples/basic_policy.csv")
389 e2, _ := NewEnforcer("examples/basic_model.conf", "examples/basic_inverse_policy.csv")
390
391 testEnforce(t, e, "alice", "data1", "read", true)
392 testEnforce(t, e, "alice", "data1", "write", false)
393
394 a2 := e2.GetAdapter()
395 e.SetAdapter(a2)
396 _ = e.LoadPolicy()
397
398 testEnforce(t, e, "alice", "data1", "read", false)
399 testEnforce(t, e, "alice", "data1", "write", true)
400}
401
402func TestSetAdapterFromFile(t *testing.T) {
403 e, _ := NewEnforcer("examples/basic_model.conf")

Callers

nothing calls this directly

Calls 5

GetAdapterMethod · 0.95
SetAdapterMethod · 0.95
LoadPolicyMethod · 0.95
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…