f.TestContainerOutput("substitution in volume subpath",pod,0,[]string{
"0",
})
})
/*
Testname: var-expansion-subpath-with-backticks
Description: Make sure a container's subpath can not be set using an
expansion of environment variables when backticks are supplied.
*/
It("should fail substituting values in a volume subpath with backticks [Feature:VolumeSubpathEnvExpansion][NodeAlphaFeature:VolumeSubpathEnvExpansion][Slow]",func(){
podName:="var-expansion-"+string(uuid.NewUUID())
pod:=&v1.Pod{
ObjectMeta:metav1.ObjectMeta{
Name:podName,
Labels:map[string]string{"name":podName},
},
Spec:v1.PodSpec{
Containers:[]v1.Container{
{
Name:"dapi-container",
Image:busyboxImage,
Env:[]v1.EnvVar{
{
Name:"POD_NAME",
Value:"..",
},
},
VolumeMounts:[]v1.VolumeMount{
{
Name:"workdir1",
MountPath:"/logscontainer",
SubPath:"$(POD_NAME)",
},
},
},
},
RestartPolicy:v1.RestartPolicyNever,
Volumes:[]v1.Volume{
{
Name:"workdir1",
VolumeSource:v1.VolumeSource{
EmptyDir:&v1.EmptyDirVolumeSource{},
},
},
},
},
}
// Pod should fail
testPodFailSubpath(f,pod,"SubPath `..`: must not contain '..'")
Description: Make sure a container's subpath can not be set using an
expansion of environment variables when absoluete path is supplied.
*/
It("should fail substituting values in a volume subpath with absolute path [Feature:VolumeSubpathEnvExpansion][NodeAlphaFeature:VolumeSubpathEnvExpansion][Slow]",func(){
podName:="var-expansion-"+string(uuid.NewUUID())
pod:=&v1.Pod{
ObjectMeta:metav1.ObjectMeta{
Name:podName,
Labels:map[string]string{"name":podName},
},
Spec:v1.PodSpec{
Containers:[]v1.Container{
{
Name:"dapi-container",
Image:busyboxImage,
Env:[]v1.EnvVar{
{
Name:"POD_NAME",
Value:"/tmp",
},
},
VolumeMounts:[]v1.VolumeMount{
{
Name:"workdir1",
MountPath:"/logscontainer",
SubPath:"$(POD_NAME)",
},
},
},
},
RestartPolicy:v1.RestartPolicyNever,
Volumes:[]v1.Volume{
{
Name:"workdir1",
VolumeSource:v1.VolumeSource{
EmptyDir:&v1.EmptyDirVolumeSource{},
},
},
},
},
}
// Pod should fail
testPodFailSubpath(f,pod,"SubPath `/tmp` must not be an absolute path")