provisioning: escape literal '$' with '$$' to avoid interpolation (#18045)
fixes #17986
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
package values
|
||||
|
||||
import (
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"gopkg.in/yaml.v2"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
func TestValues(t *testing.T) {
|
||||
Convey("Values", t, func() {
|
||||
os.Setenv("INT", "1")
|
||||
os.Setenv("STRING", "test")
|
||||
os.Setenv("EMPTYSTRING", "")
|
||||
os.Setenv("BOOL", "true")
|
||||
|
||||
Convey("IntValue", func() {
|
||||
@@ -61,6 +63,24 @@ func TestValues(t *testing.T) {
|
||||
So(d.Val.Value(), ShouldEqual, "")
|
||||
So(d.Val.Raw, ShouldEqual, "")
|
||||
})
|
||||
|
||||
Convey("empty var should have empty value", func() {
|
||||
unmarshalingTest(`val: $EMPTYSTRING`, d)
|
||||
So(d.Val.Value(), ShouldEqual, "")
|
||||
So(d.Val.Raw, ShouldEqual, "$EMPTYSTRING")
|
||||
})
|
||||
|
||||
Convey("$$ should be a literal $", func() {
|
||||
unmarshalingTest(`val: $$`, d)
|
||||
So(d.Val.Value(), ShouldEqual, "$")
|
||||
So(d.Val.Raw, ShouldEqual, "$$")
|
||||
})
|
||||
|
||||
Convey("$$ should be a literal $ and not expanded within a string", func() {
|
||||
unmarshalingTest(`val: mY,Passwo$$rd`, d)
|
||||
So(d.Val.Value(), ShouldEqual, "mY,Passwo$rd")
|
||||
So(d.Val.Raw, ShouldEqual, "mY,Passwo$$rd")
|
||||
})
|
||||
})
|
||||
|
||||
Convey("BoolValue", func() {
|
||||
@@ -199,6 +219,7 @@ func TestValues(t *testing.T) {
|
||||
Reset(func() {
|
||||
os.Unsetenv("INT")
|
||||
os.Unsetenv("STRING")
|
||||
os.Unsetenv("EMPTYSTRING")
|
||||
os.Unsetenv("BOOL")
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user