diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 2828f27918..1bd9fe4d1d 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -2394,13 +2394,12 @@ func TestBuildOnBuildOutput(t *testing.T) { } func TestBuildInvalidTag(t *testing.T) { - name := "abcd:A0123456789B0123456789C0123456789" + name := "abcd:" + makeRandomString(200) defer deleteImages(name) _, out, err := buildImageWithOut(name, "FROM scratch\nMAINTAINER quux\n", true) // if the error doesnt check for illegal tag name, or the image is built // then this should fail - if !strings.Contains(err.Error(), "Illegal tag name") || - strings.Contains(out, "Sending build context to Docker daemon") { + if !strings.Contains(out, "Illegal tag name") || strings.Contains(out, "Sending build context to Docker daemon") { t.Fatalf("failed to stop before building. Error: %s, Output: %s", err, out) } logDone("build - invalid tag") diff --git a/integration-cli/docker_cli_tag_test.go b/integration-cli/docker_cli_tag_test.go index 9c5f6990ca..815416f208 100644 --- a/integration-cli/docker_cli_tag_test.go +++ b/integration-cli/docker_cli_tag_test.go @@ -54,8 +54,9 @@ func TestTagInvalidUnprefixedRepo(t *testing.T) { // ensure we don't allow the use of invalid tags; these tag operations should fail func TestTagInvalidPrefixedRepo(t *testing.T) { + long_tag := makeRandomString(121) - invalidTags := []string{"repo:fo$z$", "repo:Foo@3cc", "repo:Foo$3", "repo:Foo*3", "repo:Fo^3", "repo:Foo!3", "repo:%goodbye", "repo:#hashtagit", "repo:F)xcz(", "repo:fwaytoolongandwaymorethan30characterslong", "repo:-foo", "repo:.."} + invalidTags := []string{"repo:fo$z$", "repo:Foo@3cc", "repo:Foo$3", "repo:Foo*3", "repo:Fo^3", "repo:Foo!3", "repo:%goodbye", "repo:#hashtagit", "repo:F)xcz(", "repo:-foo", "repo:..", long_tag} for _, repotag := range invalidTags { tagCmd := exec.Command(dockerBinary, "tag", "busybox", repotag) diff --git a/integration-cli/utils.go b/integration-cli/utils.go index b1498f652c..f3f128e329 100644 --- a/integration-cli/utils.go +++ b/integration-cli/utils.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "io" + "math/rand" "net/http" "net/http/httptest" "os" @@ -255,3 +256,13 @@ func copyWithCP(source, target string) error { } return nil } + +func makeRandomString(n int) string { + // make a really long string + letters := []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + b := make([]byte, n) + for i := range b { + b[i] = letters[rand.Intn(len(letters))] + } + return string(b) +}