@@ -80,7 +80,7 @@ func TestPublishEndpoint(t *testing.T) {
8080 {
8181 name : "successful publish with no auth (AuthMethodNone)" ,
8282 requestBody : apiv0.ServerJSON {
83- Name : "example/test-server" ,
83+ Name : "com. example/test-server" ,
8484 Description : "A test server without auth" ,
8585 Repository : model.Repository {
8686 URL : "https://github.com/example/test-server" ,
@@ -92,7 +92,7 @@ func TestPublishEndpoint(t *testing.T) {
9292 tokenClaims : & auth.JWTClaims {
9393 AuthMethod : auth .MethodNone ,
9494 Permissions : []auth.Permission {
95- {Action : auth .PermissionActionPublish , ResourcePattern : "example/ *" },
95+ {Action : auth .PermissionActionPublish , ResourcePattern : "*" },
9696 },
9797 },
9898 setupRegistryService : func (_ service.RegistryService ) {
@@ -127,7 +127,7 @@ func TestPublishEndpoint(t *testing.T) {
127127 {
128128 name : "invalid token" ,
129129 requestBody : apiv0.ServerJSON {
130- Name : "test-server" ,
130+ Name : "com.example/ test-server" ,
131131 Description : "A test server" ,
132132 Version : "1.0.0" ,
133133 },
@@ -165,7 +165,7 @@ func TestPublishEndpoint(t *testing.T) {
165165 {
166166 name : "registry service error" ,
167167 requestBody : apiv0.ServerJSON {
168- Name : "example/test-server" ,
168+ Name : "com. example/test-server" ,
169169 Description : "A test server" ,
170170 Version : "1.0.0" ,
171171 Repository : model.Repository {
@@ -183,7 +183,7 @@ func TestPublishEndpoint(t *testing.T) {
183183 setupRegistryService : func (registry service.RegistryService ) {
184184 // Pre-publish the same server to cause duplicate version error
185185 existingServer := apiv0.ServerJSON {
186- Name : "example/test-server" ,
186+ Name : "com. example/test-server" ,
187187 Description : "Existing test server" ,
188188 Version : "1.0.0" ,
189189 Repository : model.Repository {
@@ -194,7 +194,7 @@ func TestPublishEndpoint(t *testing.T) {
194194 }
195195 _ , _ = registry .Publish (existingServer )
196196 },
197- expectedStatus : http .StatusBadRequest ,
197+ expectedStatus : http .StatusUnprocessableEntity ,
198198 expectedError : "invalid version: cannot publish duplicate version" ,
199199 },
200200 {
@@ -243,7 +243,7 @@ func TestPublishEndpoint(t *testing.T) {
243243 },
244244 },
245245 setupRegistryService : func (_ service.RegistryService ) {},
246- expectedStatus : http .StatusBadRequest ,
246+ expectedStatus : http .StatusUnprocessableEntity ,
247247 expectedError : "server name cannot contain multiple slashes" ,
248248 },
249249 {
@@ -260,7 +260,7 @@ func TestPublishEndpoint(t *testing.T) {
260260 },
261261 },
262262 setupRegistryService : func (_ service.RegistryService ) {},
263- expectedStatus : http .StatusBadRequest ,
263+ expectedStatus : http .StatusUnprocessableEntity ,
264264 expectedError : "server name cannot contain multiple slashes" ,
265265 },
266266 {
@@ -277,7 +277,7 @@ func TestPublishEndpoint(t *testing.T) {
277277 },
278278 },
279279 setupRegistryService : func (_ service.RegistryService ) {},
280- expectedStatus : http .StatusBadRequest ,
280+ expectedStatus : http .StatusUnprocessableEntity ,
281281 expectedError : "server name cannot contain multiple slashes" ,
282282 },
283283 {
@@ -294,7 +294,7 @@ func TestPublishEndpoint(t *testing.T) {
294294 },
295295 },
296296 setupRegistryService : func (_ service.RegistryService ) {},
297- expectedStatus : http .StatusBadRequest ,
297+ expectedStatus : http .StatusUnprocessableEntity ,
298298 expectedError : "server name cannot contain multiple slashes" ,
299299 },
300300 {
@@ -311,7 +311,7 @@ func TestPublishEndpoint(t *testing.T) {
311311 },
312312 },
313313 setupRegistryService : func (_ service.RegistryService ) {},
314- expectedStatus : http .StatusBadRequest ,
314+ expectedStatus : http .StatusUnprocessableEntity ,
315315 expectedError : "server name cannot contain multiple slashes" ,
316316 },
317317 {
@@ -349,7 +349,7 @@ func TestPublishEndpoint(t *testing.T) {
349349 },
350350 },
351351 setupRegistryService : func (_ service.RegistryService ) {},
352- expectedStatus : http .StatusBadRequest ,
352+ expectedStatus : http .StatusUnprocessableEntity ,
353353 expectedError : "server name cannot contain multiple slashes" ,
354354 },
355355 }
@@ -433,25 +433,25 @@ func TestPublishEndpoint_MultipleSlashesEdgeCases(t *testing.T) {
433433 {
434434 name : "invalid - trailing slash after valid name" ,
435435 serverName : "com.example/server/" ,
436- expectedStatus : http .StatusBadRequest ,
436+ expectedStatus : http .StatusUnprocessableEntity ,
437437 description : "Trailing slash creates multiple slashes" ,
438438 },
439439 {
440440 name : "invalid - leading and middle slash" ,
441441 serverName : "/com.example/server" ,
442- expectedStatus : http .StatusBadRequest ,
442+ expectedStatus : http .StatusUnprocessableEntity ,
443443 description : "Leading slash with middle slash" ,
444444 },
445445 {
446446 name : "invalid - file system style path" ,
447447 serverName : "usr/local/bin/server" ,
448- expectedStatus : http .StatusBadRequest ,
448+ expectedStatus : http .StatusUnprocessableEntity ,
449449 description : "File system style paths should be rejected" ,
450450 },
451451 {
452452 name : "invalid - version-like suffix" ,
453453 serverName : "com.example/server/v1.0.0" ,
454- expectedStatus : http .StatusBadRequest ,
454+ expectedStatus : http .StatusUnprocessableEntity ,
455455 description : "Version suffixes with slash should be rejected" ,
456456 },
457457 }
@@ -502,9 +502,10 @@ func TestPublishEndpoint_MultipleSlashesEdgeCases(t *testing.T) {
502502 assert .Equal (t , tc .expectedStatus , rr .Code ,
503503 "%s: expected status %d, got %d" , tc .description , tc .expectedStatus , rr .Code )
504504
505- if tc .expectedStatus == http .StatusBadRequest {
506- assert .Contains (t , rr .Body .String (), "server name cannot contain multiple slashes" ,
507- "%s: should contain specific error message" , tc .description )
505+ if tc .expectedStatus == http .StatusUnprocessableEntity {
506+ // Huma returns a generic pattern validation error
507+ assert .Contains (t , rr .Body .String (), "pattern" ,
508+ "%s: should contain pattern validation error" , tc .description )
508509 }
509510 })
510511 }
0 commit comments