mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 13:41:36 +00:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user