fix api server resize&execResize
| ... | ... |
@@ -1015,11 +1015,11 @@ func postContainersResize(eng *engine.Engine, version version.Version, w http.Re |
| 1015 | 1015 |
|
| 1016 | 1016 |
height, err := strconv.Atoi(r.Form.Get("h"))
|
| 1017 | 1017 |
if err != nil {
|
| 1018 |
- return nil |
|
| 1018 |
+ return err |
|
| 1019 | 1019 |
} |
| 1020 | 1020 |
width, err := strconv.Atoi(r.Form.Get("w"))
|
| 1021 | 1021 |
if err != nil {
|
| 1022 |
- return nil |
|
| 1022 |
+ return err |
|
| 1023 | 1023 |
} |
| 1024 | 1024 |
|
| 1025 | 1025 |
d := getDaemon(eng) |
| ... | ... |
@@ -1028,11 +1028,7 @@ func postContainersResize(eng *engine.Engine, version version.Version, w http.Re |
| 1028 | 1028 |
return err |
| 1029 | 1029 |
} |
| 1030 | 1030 |
|
| 1031 |
- if err := cont.Resize(height, width); err != nil {
|
|
| 1032 |
- return err |
|
| 1033 |
- } |
|
| 1034 |
- |
|
| 1035 |
- return nil |
|
| 1031 |
+ return cont.Resize(height, width) |
|
| 1036 | 1032 |
} |
| 1037 | 1033 |
|
| 1038 | 1034 |
func postContainersAttach(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
| ... | ... |
@@ -1395,19 +1391,16 @@ func postContainerExecResize(eng *engine.Engine, version version.Version, w http |
| 1395 | 1395 |
|
| 1396 | 1396 |
height, err := strconv.Atoi(r.Form.Get("h"))
|
| 1397 | 1397 |
if err != nil {
|
| 1398 |
- return nil |
|
| 1398 |
+ return err |
|
| 1399 | 1399 |
} |
| 1400 | 1400 |
width, err := strconv.Atoi(r.Form.Get("w"))
|
| 1401 | 1401 |
if err != nil {
|
| 1402 |
- return nil |
|
| 1402 |
+ return err |
|
| 1403 | 1403 |
} |
| 1404 | 1404 |
|
| 1405 | 1405 |
d := getDaemon(eng) |
| 1406 |
- if err := d.ContainerExecResize(vars["name"], height, width); err != nil {
|
|
| 1407 |
- return err |
|
| 1408 |
- } |
|
| 1409 | 1406 |
|
| 1410 |
- return nil |
|
| 1407 |
+ return d.ContainerExecResize(vars["name"], height, width) |
|
| 1411 | 1408 |
} |
| 1412 | 1409 |
|
| 1413 | 1410 |
func optionsHandler(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
| 1414 | 1411 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,25 @@ |
| 0 |
+package main |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "os/exec" |
|
| 4 |
+ "strings" |
|
| 5 |
+ "testing" |
|
| 6 |
+) |
|
| 7 |
+ |
|
| 8 |
+func TestExecResizeApiHeightWidthNoInt(t *testing.T) {
|
|
| 9 |
+ runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top") |
|
| 10 |
+ out, _, err := runCommandWithOutput(runCmd) |
|
| 11 |
+ if err != nil {
|
|
| 12 |
+ t.Fatalf(out, err) |
|
| 13 |
+ } |
|
| 14 |
+ defer deleteAllContainers() |
|
| 15 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
| 16 |
+ |
|
| 17 |
+ endpoint := "/exec/" + cleanedContainerID + "/resize?h=foo&w=bar" |
|
| 18 |
+ _, err = sockRequest("POST", endpoint, nil)
|
|
| 19 |
+ if err == nil {
|
|
| 20 |
+ t.Fatal("Expected exec resize Request to fail")
|
|
| 21 |
+ } |
|
| 22 |
+ |
|
| 23 |
+ logDone("container exec resize - height, width no int fail")
|
|
| 24 |
+} |
| ... | ... |
@@ -24,6 +24,24 @@ func TestResizeApiResponse(t *testing.T) {
|
| 24 | 24 |
logDone("container resize - when started")
|
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 |
+func TestResizeApiHeightWidthNoInt(t *testing.T) {
|
|
| 28 |
+ runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top") |
|
| 29 |
+ out, _, err := runCommandWithOutput(runCmd) |
|
| 30 |
+ if err != nil {
|
|
| 31 |
+ t.Fatalf(out, err) |
|
| 32 |
+ } |
|
| 33 |
+ defer deleteAllContainers() |
|
| 34 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
| 35 |
+ |
|
| 36 |
+ endpoint := "/containers/" + cleanedContainerID + "/resize?h=foo&w=bar" |
|
| 37 |
+ _, err = sockRequest("POST", endpoint, nil)
|
|
| 38 |
+ if err == nil {
|
|
| 39 |
+ t.Fatal("Expected resize Request to fail")
|
|
| 40 |
+ } |
|
| 41 |
+ |
|
| 42 |
+ logDone("container resize - height, width no int fail")
|
|
| 43 |
+} |
|
| 44 |
+ |
|
| 27 | 45 |
func TestResizeApiResponseWhenContainerNotStarted(t *testing.T) {
|
| 28 | 46 |
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true") |
| 29 | 47 |
out, _, err := runCommandWithOutput(runCmd) |