@@ -18,42 +18,38 @@ func TestValidateOCI_RegistryAllowlist(t *testing.T) {
1818 expectError bool
1919 errorMsg string
2020 }{
21- // Allowed registries - these should NOT fail with "unsupported registry"
21+ // Allowed registries - use real public images that exist
22+ // These should fail with "missing required annotation" (no MCP label)
23+ // NOT with "unsupported registry", "does not exist", or "is private" errors
2224 {
23- name : "Docker Hub should be allowed" ,
24- identifier : "docker.io/test/image:latest" ,
25- // Will fail on image not found, but registry should be accepted
25+ name : "Docker Hub should be allowed" ,
26+ identifier : "docker.io/library/alpine:latest" ,
2627 expectError : true ,
28+ errorMsg : "missing required annotation" ,
2729 },
2830 {
29- name : "Docker Hub without explicit registry should default and be allowed" ,
30- identifier : "test/image:latest" ,
31- // Will fail on image not found, but registry should be accepted
31+ name : "Docker Hub without explicit registry should default and be allowed" ,
32+ identifier : "library/hello-world:latest" ,
3233 expectError : true ,
34+ errorMsg : "missing required annotation" ,
3335 },
3436 {
35- name : "GHCR should be allowed" ,
36- identifier : "ghcr.io/test/image:latest" ,
37- // Will fail on image fetch, but registry should be accepted
37+ name : "GHCR should be allowed" ,
38+ identifier : "ghcr.io/containerbase/base:latest" ,
3839 expectError : true ,
40+ errorMsg : "missing required annotation" ,
3941 },
4042 {
41- name : "Artifact Registry us-central1 should be allowed" ,
42- identifier : "us-central1-docker.pkg.dev/project/repo/image:latest" ,
43- // Will fail on image fetch, but registry should be accepted
43+ name : "Artifact Registry regional should be allowed" ,
44+ identifier : "us-central1-docker.pkg.dev/database-toolbox/toolbox/toolbox:latest" ,
4445 expectError : true ,
46+ errorMsg : "missing required annotation" ,
4547 },
4648 {
47- name : "Artifact Registry europe-west1 should be allowed" ,
48- identifier : "europe-west1-docker.pkg.dev/project/repo/image:latest" ,
49- // Will fail on image fetch, but registry should be accepted
50- expectError : true ,
51- },
52- {
53- name : "Artifact Registry multi-region us should be allowed" ,
54- identifier : "us-docker.pkg.dev/project/repo/image:latest" ,
55- // Will fail on image fetch, but registry should be accepted
49+ name : "Artifact Registry multi-region should be allowed" ,
50+ identifier : "us-docker.pkg.dev/berglas/berglas/berglas:latest" ,
5651 expectError : true ,
52+ errorMsg : "missing required annotation" ,
5753 },
5854
5955 // Disallowed registries
@@ -106,13 +102,8 @@ func TestValidateOCI_RegistryAllowlist(t *testing.T) {
106102
107103 if tt .expectError {
108104 assert .Error (t , err )
109- if tt .errorMsg != "" {
110- // Should contain the specific error message
111- assert .Contains (t , err .Error (), tt .errorMsg )
112- } else {
113- // For allowed registries, should NOT be "unsupported registry" error
114- assert .NotContains (t , err .Error (), "unsupported OCI registry" )
115- }
105+ // Should contain the specific error message
106+ assert .Contains (t , err .Error (), tt .errorMsg )
116107 } else {
117108 assert .NoError (t , err )
118109 }
@@ -210,3 +201,32 @@ func TestValidateOCI_EmptyIdentifier(t *testing.T) {
210201 assert .Error (t , err )
211202 assert .Contains (t , err .Error (), "package identifier is required" )
212203}
204+
205+ func TestValidateOCI_SuccessfulValidation (t * testing.T ) {
206+ ctx := context .Background ()
207+
208+ // Test with a real MCP server image that has the correct label
209+ pkg := model.Package {
210+ RegistryType : model .RegistryTypeOCI ,
211+ Identifier : "ghcr.io/github/github-mcp-server:latest" ,
212+ }
213+
214+ err := registries .ValidateOCI (ctx , pkg , "io.github.github/github-mcp-server" )
215+ assert .NoError (t , err )
216+ }
217+
218+ func TestValidateOCI_LabelMismatch (t * testing.T ) {
219+ ctx := context .Background ()
220+
221+ // Test with a real MCP server image but wrong expected server name
222+ // This should fail because the label doesn't match
223+ pkg := model.Package {
224+ RegistryType : model .RegistryTypeOCI ,
225+ Identifier : "ghcr.io/github/github-mcp-server:latest" ,
226+ }
227+
228+ err := registries .ValidateOCI (ctx , pkg , "io.github.github/github-mcp-server-mismatch" )
229+ assert .Error (t , err )
230+ assert .Contains (t , err .Error (), "ownership validation failed" )
231+ assert .Contains (t , err .Error (), "Expected annotation" )
232+ }
0 commit comments