Signed-off-by: Antonio Murdaca <me@runcom.ninja>
| ... | ... |
@@ -1036,11 +1036,11 @@ func postContainersResize(eng *engine.Engine, version version.Version, w http.Re |
| 1036 | 1036 |
|
| 1037 | 1037 |
height, err := strconv.Atoi(r.Form.Get("h"))
|
| 1038 | 1038 |
if err != nil {
|
| 1039 |
- return nil |
|
| 1039 |
+ return err |
|
| 1040 | 1040 |
} |
| 1041 | 1041 |
width, err := strconv.Atoi(r.Form.Get("w"))
|
| 1042 | 1042 |
if err != nil {
|
| 1043 |
- return nil |
|
| 1043 |
+ return err |
|
| 1044 | 1044 |
} |
| 1045 | 1045 |
|
| 1046 | 1046 |
d := getDaemon(eng) |
| ... | ... |
@@ -1049,11 +1049,7 @@ func postContainersResize(eng *engine.Engine, version version.Version, w http.Re |
| 1049 | 1049 |
return err |
| 1050 | 1050 |
} |
| 1051 | 1051 |
|
| 1052 |
- if err := cont.Resize(height, width); err != nil {
|
|
| 1053 |
- return err |
|
| 1054 |
- } |
|
| 1055 |
- |
|
| 1056 |
- return nil |
|
| 1052 |
+ return cont.Resize(height, width) |
|
| 1057 | 1053 |
} |
| 1058 | 1054 |
|
| 1059 | 1055 |
func postContainersAttach(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
| ... | ... |
@@ -1416,19 +1412,16 @@ func postContainerExecResize(eng *engine.Engine, version version.Version, w http |
| 1416 | 1416 |
|
| 1417 | 1417 |
height, err := strconv.Atoi(r.Form.Get("h"))
|
| 1418 | 1418 |
if err != nil {
|
| 1419 |
- return nil |
|
| 1419 |
+ return err |
|
| 1420 | 1420 |
} |
| 1421 | 1421 |
width, err := strconv.Atoi(r.Form.Get("w"))
|
| 1422 | 1422 |
if err != nil {
|
| 1423 |
- return nil |
|
| 1423 |
+ return err |
|
| 1424 | 1424 |
} |
| 1425 | 1425 |
|
| 1426 | 1426 |
d := getDaemon(eng) |
| 1427 |
- if err := d.ContainerExecResize(vars["name"], height, width); err != nil {
|
|
| 1428 |
- return err |
|
| 1429 |
- } |
|
| 1430 | 1427 |
|
| 1431 |
- return nil |
|
| 1428 |
+ return d.ContainerExecResize(vars["name"], height, width) |
|
| 1432 | 1429 |
} |
| 1433 | 1430 |
|
| 1434 | 1431 |
func optionsHandler(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
| 1435 | 1432 |
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) |