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

Function TestSyncedEnforcerSelfRemovePolicy

enforcer_synced_test.go:177–213  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

175}
176
177func TestSyncedEnforcerSelfRemovePolicy(t *testing.T) {
178 for i := 0; i < 10; i++ {
179 e, _ := NewSyncedEnforcer("examples/basic_model.conf", "examples/basic_policy.csv")
180 go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user1", "data1", "read"}) }()
181 go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user2", "data2", "read"}) }()
182 go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user3", "data3", "read"}) }()
183 go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user4", "data4", "read"}) }()
184 go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user5", "data5", "read"}) }()
185 go func() { _, _ = e.SelfAddPolicy("p", "p", []string{"user6", "data6", "read"}) }()
186
187 time.Sleep(100 * time.Millisecond)
188
189 testSyncedEnforcerGetPolicy(t, e, [][]string{
190 {"alice", "data1", "read"},
191 {"bob", "data2", "write"},
192 {"user1", "data1", "read"},
193 {"user2", "data2", "read"},
194 {"user3", "data3", "read"},
195 {"user4", "data4", "read"},
196 {"user5", "data5", "read"},
197 {"user6", "data6", "read"},
198 })
199
200 go func() { _, _ = e.SelfRemovePolicy("p", "p", []string{"user1", "data1", "read"}) }()
201 go func() { _, _ = e.SelfRemovePolicy("p", "p", []string{"user2", "data2", "read"}) }()
202 go func() { _, _ = e.SelfRemovePolicy("p", "p", []string{"user3", "data3", "read"}) }()
203 go func() { _, _ = e.SelfRemovePolicy("p", "p", []string{"user4", "data4", "read"}) }()
204 go func() { _, _ = e.SelfRemovePolicy("p", "p", []string{"user5", "data5", "read"}) }()
205 go func() { _, _ = e.SelfRemovePolicy("p", "p", []string{"user6", "data6", "read"}) }()
206
207 time.Sleep(100 * time.Millisecond)
208 testSyncedEnforcerGetPolicy(t, e, [][]string{
209 {"alice", "data1", "read"},
210 {"bob", "data2", "write"},
211 })
212 }
213}
214
215func TestSyncedEnforcerSelfRemovePolicies(t *testing.T) {
216 for i := 0; i < 10; i++ {

Callers

nothing calls this directly

Calls 4

SelfAddPolicyMethod · 0.95
SelfRemovePolicyMethod · 0.95
NewSyncedEnforcerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…