(t *testing.T)
| 207 | } |
| 208 | |
| 209 | func TestIEnforcerContext_SelfMethods(t *testing.T) { |
| 210 | e, err := NewContextEnforcer("examples/rbac_model.conf", "examples/rbac_policy.csv") |
| 211 | if err != nil { |
| 212 | t.Fatalf("NewContextEnforcer failed: %v", err) |
| 213 | } |
| 214 | |
| 215 | ctx := context.Background() |
| 216 | |
| 217 | added, err := e.SelfAddPolicyCtx(ctx, "p", "p", []string{"eve", "data3", "read"}) |
| 218 | if err != nil { |
| 219 | t.Fatalf("SelfAddPolicyCtx failed: %v", err) |
| 220 | } |
| 221 | if !added { |
| 222 | t.Error("SelfAddPolicyCtx should return true for new policy") |
| 223 | } |
| 224 | |
| 225 | removed, err := e.SelfRemovePolicyCtx(ctx, "p", "p", []string{"eve", "data3", "read"}) |
| 226 | if err != nil { |
| 227 | t.Fatalf("SelfRemovePolicyCtx failed: %v", err) |
| 228 | } |
| 229 | if !removed { |
| 230 | t.Error("SelfRemovePolicyCtx should return true for existing policy") |
| 231 | } |
| 232 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…