Fix regression in containers attach/wsattach api, return not found before hijacking

Signed-off-by: Antonio Murdaca <runcom@linux.com>
This commit is contained in:
Antonio Murdaca
2015-07-01 18:16:17 +02:00
parent bb2cd98b28
commit 88d32a6109
3 changed files with 36 additions and 14 deletions
+22
View File
@@ -2,6 +2,7 @@ package main
import (
"bytes"
"net/http"
"os/exec"
"strings"
"time"
@@ -76,3 +77,24 @@ func (s *DockerSuite) TestGetContainersAttachWebsocket(c *check.C) {
c.Fatal("Expected output on websocket to match input")
}
}
// regression gh14320
func (s *DockerSuite) TestPostContainersAttachContainerNotFound(c *check.C) {
status, body, err := sockRequest("POST", "/containers/doesnotexist/attach", nil)
c.Assert(status, check.Equals, http.StatusNotFound)
c.Assert(err, check.IsNil)
expected := "no such id: doesnotexist\n"
if !strings.Contains(string(body), expected) {
c.Fatalf("Expected response body to contain %q", expected)
}
}
func (s *DockerSuite) TestGetContainersWsAttachContainerNotFound(c *check.C) {
status, body, err := sockRequest("GET", "/containers/doesnotexist/attach/ws", nil)
c.Assert(status, check.Equals, http.StatusNotFound)
c.Assert(err, check.IsNil)
expected := "no such id: doesnotexist\n"
if !strings.Contains(string(body), expected) {
c.Fatalf("Expected response body to contain %q", expected)
}
}