(t *testing.T)
| 295 | } |
| 296 | |
| 297 | func TestSyncedEnforcerSelfUpdatePolicy(t *testing.T) { |
| 298 | for i := 0; i < 10; i++ { |
| 299 | e, _ := NewSyncedEnforcer("examples/basic_model.conf", "examples/basic_policy.csv") |
| 300 | go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user1", "data1", "read"}) }() |
| 301 | go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user2", "data2", "read"}) }() |
| 302 | go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user3", "data3", "read"}) }() |
| 303 | go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user4", "data4", "read"}) }() |
| 304 | go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user5", "data5", "read"}) }() |
| 305 | go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user6", "data6", "read"}) }() |
| 306 | time.Sleep(100 * time.Millisecond) |
| 307 | |
| 308 | testSyncedEnforcerGetPolicy(t, e, [][]string{ |
| 309 | {"alice", "data1", "read"}, |
| 310 | {"bob", "data2", "write"}, |
| 311 | {"user1", "data1", "read"}, |
| 312 | {"user2", "data2", "read"}, |
| 313 | {"user3", "data3", "read"}, |
| 314 | {"user4", "data4", "read"}, |
| 315 | {"user5", "data5", "read"}, |
| 316 | {"user6", "data6", "read"}, |
| 317 | }) |
| 318 | |
| 319 | go func() { |
| 320 | _, _ = e.SelfUpdatePolicy("p", "p", []string{"user1", "data1", "read"}, []string{"user1", "data1", "write"}) |
| 321 | }() |
| 322 | go func() { |
| 323 | _, _ = e.SelfUpdatePolicy("p", "p", []string{"user2", "data2", "read"}, []string{"user2", "data2", "write"}) |
| 324 | }() |
| 325 | go func() { |
| 326 | _, _ = e.SelfUpdatePolicy("p", "p", []string{"user3", "data3", "read"}, []string{"user3", "data3", "write"}) |
| 327 | }() |
| 328 | go func() { |
| 329 | _, _ = e.SelfUpdatePolicy("p", "p", []string{"user4", "data4", "read"}, []string{"user4", "data4", "write"}) |
| 330 | }() |
| 331 | go func() { |
| 332 | _, _ = e.SelfUpdatePolicy("p", "p", []string{"user5", "data5", "read"}, []string{"user5", "data5", "write"}) |
| 333 | }() |
| 334 | go func() { |
| 335 | _, _ = e.SelfUpdatePolicy("p", "p", []string{"user6", "data6", "read"}, []string{"user6", "data6", "write"}) |
| 336 | }() |
| 337 | |
| 338 | time.Sleep(100 * time.Millisecond) |
| 339 | testSyncedEnforcerGetPolicy(t, e, [][]string{ |
| 340 | {"alice", "data1", "read"}, |
| 341 | {"bob", "data2", "write"}, |
| 342 | {"user1", "data1", "write"}, |
| 343 | {"user2", "data2", "write"}, |
| 344 | {"user3", "data3", "write"}, |
| 345 | {"user4", "data4", "write"}, |
| 346 | {"user5", "data5", "write"}, |
| 347 | {"user6", "data6", "write"}, |
| 348 | }) |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | func TestSyncedEnforcerSelfUpdatePolicies(t *testing.T) { |
| 353 | for i := 0; i < 10; i++ { |
nothing calls this directly
no test coverage detected
searching dependent graphs…