|
@@ -42,3 +42,43 @@ func (s *DockerSuite) TestAPICreateWithNotExistImage(c *check.C) {
|
|
c.Assert(getErrorMessage(c, body), checker.Equals, expected)
|
|
c.Assert(getErrorMessage(c, body), checker.Equals, expected)
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// Test for #25099
|
|
|
|
+func (s *DockerSuite) TestAPICreateEmptyEnv(c *check.C) {
|
|
|
|
+ name := "test1"
|
|
|
|
+ config := map[string]interface{}{
|
|
|
|
+ "Image": "busybox",
|
|
|
|
+ "Env": []string{"", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"},
|
|
|
|
+ "Cmd": []string{"true"},
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ status, body, err := sockRequest("POST", "/containers/create?name="+name, config)
|
|
|
|
+ c.Assert(err, check.IsNil)
|
|
|
|
+ c.Assert(status, check.Equals, http.StatusInternalServerError)
|
|
|
|
+ expected := "invalid environment variable:"
|
|
|
|
+ c.Assert(getErrorMessage(c, body), checker.Contains, expected)
|
|
|
|
+
|
|
|
|
+ name = "test2"
|
|
|
|
+ config = map[string]interface{}{
|
|
|
|
+ "Image": "busybox",
|
|
|
|
+ "Env": []string{"=", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"},
|
|
|
|
+ "Cmd": []string{"true"},
|
|
|
|
+ }
|
|
|
|
+ status, body, err = sockRequest("POST", "/containers/create?name="+name, config)
|
|
|
|
+ c.Assert(err, check.IsNil)
|
|
|
|
+ c.Assert(status, check.Equals, http.StatusInternalServerError)
|
|
|
|
+ expected = "invalid environment variable: ="
|
|
|
|
+ c.Assert(getErrorMessage(c, body), checker.Contains, expected)
|
|
|
|
+
|
|
|
|
+ name = "test3"
|
|
|
|
+ config = map[string]interface{}{
|
|
|
|
+ "Image": "busybox",
|
|
|
|
+ "Env": []string{"=foo", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"},
|
|
|
|
+ "Cmd": []string{"true"},
|
|
|
|
+ }
|
|
|
|
+ status, body, err = sockRequest("POST", "/containers/create?name="+name, config)
|
|
|
|
+ c.Assert(err, check.IsNil)
|
|
|
|
+ c.Assert(status, check.Equals, http.StatusInternalServerError)
|
|
|
|
+ expected = "invalid environment variable: =foo"
|
|
|
|
+ c.Assert(getErrorMessage(c, body), checker.Contains, expected)
|
|
|
|
+}
|