@@ -12,20 +12,28 @@ func TestValidateDockerImageName(t *testing.T) {
1212 image string
1313 expected bool
1414 }{
15- // Valid image names
15+ // Valid image names (following Docker and OCI standards)
1616 {"Valid image name without registry or tag" , "ubuntu" , true },
1717 {"Valid image name with namespace" , "library/ubuntu" , true },
1818 {"Valid image name with registry" , "docker.io/library/ubuntu" , true },
1919 {"Valid image name with custom registry and port" , "localhost:5000/myproject/ubuntu" , true },
2020 {"Valid image name with tag" , "myregistry/myproject/ubuntu:latest" , true },
21- {"Valid image name with digest" , "myregistry/myproject/ubuntu@sha256:abc123" , true },
21+ {"Valid image name with version tag" , "nginx:1.21.0" , true },
22+ {"Valid image name with custom tag" , "myapp:v1.0.0-beta" , true },
23+ {"Valid image name with underscore" , "my_project/app:latest" , true },
24+ {"Valid image name with multiple slashes" , "org/team/project/app:latest" , true },
25+ {"Valid image name with IP address registry" , "192.168.1.100:5000/app:latest" , true },
2226
2327 // Invalid image names
2428 {"Invalid image name with uppercase letters in repository" , "MyRegistry/MyProject/Ubuntu" , false },
2529 {"Invalid image name with invalid characters" , "invalid!@#/image/name" , false },
26- {"Invalid image name with empty repository " , "" , false },
30+ {"Invalid image name with empty string " , "" , false },
2731 {"Invalid image name with only slashes" , "///" , false },
2832 {"Invalid image name with multiple @ symbols" , "invalid@image@name" , false },
33+ {"Invalid image name with invalid tag characters" , "app:tag:with:colons" , false },
34+ {"Invalid image name with leading slash" , "/app:latest" , false },
35+ {"Invalid image name with trailing slash" , "app/:latest" , false },
36+ {"Invalid image name with consecutive slashes" , "app//name:latest" , false },
2937 }
3038
3139 for _ , tt := range tests {
0 commit comments