package main import ( "strings" "testing" ) // **A plan's id is checked once, where a call becomes a command line** (novox/hq issue 561): every argument of // plans that names a plan is refused unless it is an id the mesh gives a plan, so a quote never reaches a // command, nor the store behind it. func TestAPlanIdThatIsNoPlansIdIsRefusedBeforeACommandStarts(t *testing.T) { for _, arg := range []string{"id", "stop", "close", "retry", "go"} { for _, bad := range []string{"x' or '1'='1", "plan-1'", "plan-", "plan-1 2", "batch-1", "PLAN-1"} { args := map[string]any{arg: bad} if arg == "stop" || arg == "close" || arg == "go" { args["why"] = "a test" } argv, err := argvFor("plans", args) if err == nil { t.Errorf("plans %s %q was composed: %v", arg, bad, argv) continue } if !strings.Contains(err.Error(), "is not a plan's id") { t.Errorf("plans %s %q was refused for another reason: %v", arg, bad, err) } } for _, good := range []string{"plan-1791813626034291775", "release-1791811938267404408"} { args := map[string]any{arg: good} if arg == "stop" || arg == "close" || arg == "go" { args["why"] = "a test" } if _, err := argvFor("plans", args); err != nil { t.Errorf("plans %s %q was refused: %v", arg, good, err) } } } }