(t *testing.T)
| 213 | } |
| 214 | |
| 215 | func TestSyncedEnforcerSelfRemovePolicies(t *testing.T) { |
| 216 | for i := 0; i < 10; i++ { |
| 217 | e, _ := NewSyncedEnforcer("examples/basic_model.conf", "examples/basic_policy.csv") |
| 218 | go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user1", "data1", "read"}) }() |
| 219 | go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user2", "data2", "read"}) }() |
| 220 | go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user3", "data3", "read"}) }() |
| 221 | go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user4", "data4", "read"}) }() |
| 222 | go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user5", "data5", "read"}) }() |
| 223 | go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user6", "data6", "read"}) }() |
| 224 | |
| 225 | time.Sleep(100 * time.Millisecond) |
| 226 | |
| 227 | testSyncedEnforcerGetPolicy(t, e, [][]string{ |
| 228 | {"alice", "data1", "read"}, |
| 229 | {"bob", "data2", "write"}, |
| 230 | {"user1", "data1", "read"}, |
| 231 | {"user2", "data2", "read"}, |
| 232 | {"user3", "data3", "read"}, |
| 233 | {"user4", "data4", "read"}, |
| 234 | {"user5", "data5", "read"}, |
| 235 | {"user6", "data6", "read"}, |
| 236 | }) |
| 237 | |
| 238 | go func() { |
| 239 | _, _ = e.SelfRemovePolicies("p", "p", [][]string{{"user1", "data1", "read"}, {"user2", "data2", "read"}}) |
| 240 | }() |
| 241 | go func() { |
| 242 | _, _ = e.SelfRemovePolicies("p", "p", [][]string{{"user3", "data3", "read"}, {"user4", "data4", "read"}}) |
| 243 | }() |
| 244 | go func() { |
| 245 | _, _ = e.SelfRemovePolicies("p", "p", [][]string{{"user5", "data5", "read"}, {"user6", "data6", "read"}}) |
| 246 | }() |
| 247 | |
| 248 | time.Sleep(100 * time.Millisecond) |
| 249 | testSyncedEnforcerGetPolicy(t, e, [][]string{ |
| 250 | {"alice", "data1", "read"}, |
| 251 | {"bob", "data2", "write"}, |
| 252 | }) |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | func TestSyncedEnforcerSelfRemoveFilteredPolicy(t *testing.T) { |
| 257 | for i := 0; i < 10; i++ { |
nothing calls this directly
no test coverage detected
searching dependent graphs…