mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-07 14:32:09 +00:00
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:
@@ -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