adt-automation / goRunner

High performance testing and task automation tool
Apache License 2.0
8 stars 5 forks source link

Fix/add shell variables in the ini rule processing logic. Also add a test case. #21

Open dougwatson opened 7 years ago

dougwatson commented 7 years ago

Fix/add shell variables into the ini logic.

Then add the following test_public.ini to check that shell variables are working.

[command "shell_var"]
ReqUrl = /reqapi/test/shellVar?shellVar={$shellVar}
SessionVar = VAR (shellVar=test123)
MustCapture = VAR

Here is the goRunner_test.go that is required:

http.HandleFunc("/reqapi/test/shellVar", HandleShellVar)
os.Setenv("shellVar", "test123")
...
func HandleShellVar(w http.ResponseWriter, r *http.Request) {
        shellVar := r.URL.Query().Get("shellVar")
        fmt.Fprintf(w, "%v\n", shellVar)
}

This allows a script writer to reference shell variables in the ini rules file. Great for including sensitive or variable things (like password or specific dates) into your scripts for flexibility and to prevent these values from getting into version control.

alextwatson commented 7 years ago

I got this