(t *testing.T)
| 276 | } |
| 277 | |
| 278 | func TestDecodeNonBase64Error(t *testing.T) { |
| 279 | env := testEncodersCostsEnv(t, 1) |
| 280 | pAst, iss := env.Parse("base64.decode('abc-') == b''") |
| 281 | if iss.Err() != nil { |
| 282 | t.Fatalf("env.Parse() failed: %v", iss.Err()) |
| 283 | } |
| 284 | cAst, iss := env.Check(pAst) |
| 285 | if iss.Err() != nil { |
| 286 | t.Fatalf("env.Check() failed: %v", iss.Err()) |
| 287 | } |
| 288 | testCheckCost(t, env, cAst, nil, checker.FixedCostEstimate(2)) |
| 289 | prgOpts := []cel.ProgramOption{} |
| 290 | if cAst.IsChecked() { |
| 291 | prgOpts = append(prgOpts, cel.CostTracking(nil)) |
| 292 | } |
| 293 | prg, err := env.Program(cAst, prgOpts...) |
| 294 | if err != nil { |
| 295 | t.Fatalf("env.Program() failed: %v", err) |
| 296 | } |
| 297 | _, _, err = prg.Eval(cel.NoVars()) |
| 298 | if err == nil { |
| 299 | t.Fatal("expected eval error for non-base64 string decoding, got nil") |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | func TestJSONEncodeCostUnbounded(t *testing.T) { |
| 304 | env, err := cel.NewEnv(Encoders(EncodersVersion(1))) |
nothing calls this directly
no test coverage detected