1
0
mirror of https://github.com/moby/moby.git synced 2025-08-01 05:47:11 +03:00

Merge pull request #12655 from jlhawn/fix_12281

Validate repo name before image pull
This commit is contained in:
Jessie Frazelle
2015-04-23 13:12:12 -07:00
2 changed files with 23 additions and 0 deletions

View File

@ -139,3 +139,22 @@ func (s *DockerSuite) TestPullImageOfficialNames(c *check.C) {
}
}
}
func (s *DockerSuite) TestPullScratchNotAllowed(c *check.C) {
testRequires(c, Network)
pullCmd := exec.Command(dockerBinary, "pull", "scratch")
out, exitCode, err := runCommandWithOutput(pullCmd)
if err == nil {
c.Fatal("expected pull of scratch to fail, but it didn't")
}
if exitCode != 1 {
c.Fatalf("pulling scratch expected exit code 1, got %d", exitCode)
}
if strings.Contains(out, "Pulling repository scratch") {
c.Fatalf("pulling scratch should not have begun: %s", out)
}
if !strings.Contains(out, "'scratch' is a reserved name") {
c.Fatalf("unexpected output pulling scratch: %s", out)
}
}