Merge pull request #14322 from runcom/14320-fix-regression-attach-cont-notfound

Return not found before hijacking in attach/wsattach
This commit is contained in:
Brian Goff
2015-07-01 13:22:03 -04:00
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)
}
}