MCPcopy Create free account
hub / github.com/apache/casbin / testEnforceOrBAC

Function testEnforceOrBAC

orbac_test.go:32–39  ·  view source on GitHub ↗

TestOrBACModel tests the Organization-Based Access Control (OrBAC) model. OrBAC extends RBAC with abstraction layers: - Empower (g): Maps subjects to roles within organizations - Use (g2): Maps concrete actions to abstract activities within organizations - Consider (g3): Maps concrete objects to abs

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

Source from the content-addressed store, hash-verified

30// flexible and maintainable access control policies.
31
32func testEnforceOrBAC(t *testing.T, e *Enforcer, sub string, org string, obj string, act string, res bool) {
33 t.Helper()
34 if myRes, err := e.Enforce(sub, org, obj, act); err != nil {
35 t.Errorf("Enforce Error: %s", err)
36 } else if myRes != res {
37 t.Errorf("%s, %s, %s, %s: %t, supposed to be %t", sub, org, obj, act, myRes, res)
38 }
39}
40
41func TestOrBACModel(t *testing.T) {
42 e, err := NewEnforcer("examples/orbac_model.conf", "examples/orbac_policy.csv")

Callers 1

TestOrBACModelFunction · 0.85

Calls 1

EnforceMethod · 0.65

Tested by

no test coverage detected