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

Function TestConstraintWithoutRBAC

constraint_test.go:231–256  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

229}
230
231func TestConstraintWithoutRBAC(t *testing.T) {
232 modelText := `
233[request_definition]
234r = sub, obj, act
235
236[policy_definition]
237p = sub, obj, act
238
239[constraint_definition]
240c = sod("role1", "role2")
241
242[policy_effect]
243e = some(where (p.eft == allow))
244
245[matchers]
246m = r.sub == p.sub && r.obj == p.obj && r.act == p.act
247`
248
249 _, err := model.NewModelFromString(modelText)
250 if err == nil {
251 t.Fatal("Expected error for constraints without RBAC, got nil")
252 }
253 if err != errors.ErrConstraintRequiresRBAC {
254 t.Fatalf("Expected ErrConstraintRequiresRBAC, got: %v", err)
255 }
256}
257
258func TestConstraintParsingError(t *testing.T) {
259 modelText := `

Callers

nothing calls this directly

Calls 1

NewModelFromStringFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…