Modify repository name regex to match index

This commit is contained in:
Michael Crosby 2013-09-19 20:25:00 -07:00
parent 96593dc278
commit 9c366e092d
2 changed files with 13 additions and 3 deletions

View file

@ -70,7 +70,7 @@ func validateRepositoryName(repositoryName string) error {
if !validNamespace.MatchString(namespace) {
return fmt.Errorf("Invalid namespace name (%s), only [a-z0-9_] are allowed, size between 4 and 30", namespace)
}
validRepo := regexp.MustCompile(`^([a-zA-Z0-9-_.]+)$`)
validRepo := regexp.MustCompile(`^([a-z0-9-_.]+)$`)
if !validRepo.MatchString(name) {
return fmt.Errorf("Invalid repository name (%s), only [a-zA-Z0-9-_.] are allowed", name)
}

View file

@ -159,11 +159,11 @@ func TestPushRegistryTag(t *testing.T) {
func TestPushImageJSONIndex(t *testing.T) {
r := spawnTestRegistry(t)
imgData := []*ImgData{
&ImgData{
{
ID: "77dbf71da1d00e3fbddc480176eac8994025630c6590d11cfc8fe1209c2a1d20",
Checksum: "sha256:1ac330d56e05eef6d438586545ceff7550d3bdcb6b19961f12c5ba714ee1bb37",
},
&ImgData{
{
ID: "42d718c941f5c532ac049bf0b0ab53f0062f09a03afd4aa4a02c098e46032b9d",
Checksum: "sha256:bea7bf2e4bacd479344b737328db47b18880d09096e6674165533aa994f5e9f2",
},
@ -196,3 +196,13 @@ func TestSearchRepositories(t *testing.T) {
}
assertEqual(t, results.NumResults, 0, "Expected 0 search results")
}
func TestValidRepositoryName(t *testing.T) {
if err := validateRepositoryName("docker/docker"); err != nil {
t.Fatal(err)
}
if err := validateRepositoryName("docker/Docker"); err == nil {
t.Log("Repository name should be invalid")
t.Fail()
}
}