(t *testing.T)
| 256 | } |
| 257 | |
| 258 | func TestConstraintParsingError(t *testing.T) { |
| 259 | modelText := ` |
| 260 | [request_definition] |
| 261 | r = sub, obj, act |
| 262 | |
| 263 | [policy_definition] |
| 264 | p = sub, obj, act |
| 265 | |
| 266 | [role_definition] |
| 267 | g = _, _ |
| 268 | |
| 269 | [constraint_definition] |
| 270 | c = invalidFunction("role1", "role2") |
| 271 | |
| 272 | [policy_effect] |
| 273 | e = some(where (p.eft == allow)) |
| 274 | |
| 275 | [matchers] |
| 276 | m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act |
| 277 | ` |
| 278 | |
| 279 | _, err := model.NewModelFromString(modelText) |
| 280 | if err == nil { |
| 281 | t.Fatal("Expected parsing error for invalid constraint, got nil") |
| 282 | } |
| 283 | if !strings.Contains(err.Error(), "constraint parsing error") { |
| 284 | t.Fatalf("Expected constraint parsing error, got: %v", err) |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | func TestConstraintRollback(t *testing.T) { |
| 289 | modelText := ` |
nothing calls this directly
no test coverage detected
searching dependent graphs…