@@ -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 : "com. example/*" },
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 {
@@ -224,7 +224,6 @@ func TestPublishEndpoint(t *testing.T) {
224224 setupRegistryService : func (_ service.RegistryService ) {},
225225 expectedStatus : http .StatusOK ,
226226 },
227- // IB-2-registry: Integration test for multi-slash server name rejection
228227 {
229228 name : "invalid server name - multiple slashes (two slashes)" ,
230229 requestBody : apiv0.ServerJSON {
@@ -245,7 +244,7 @@ func TestPublishEndpoint(t *testing.T) {
245244 },
246245 setupRegistryService : func (_ service.RegistryService ) {},
247246 expectedStatus : http .StatusBadRequest ,
248- expectedError : "server name format is invalid: must contain exactly one slash " ,
247+ expectedError : "server name cannot contain multiple slashes " ,
249248 },
250249 {
251250 name : "invalid server name - multiple slashes (three slashes)" ,
@@ -262,7 +261,7 @@ func TestPublishEndpoint(t *testing.T) {
262261 },
263262 setupRegistryService : func (_ service.RegistryService ) {},
264263 expectedStatus : http .StatusBadRequest ,
265- expectedError : "server name format is invalid: must contain exactly one slash " ,
264+ expectedError : "server name cannot contain multiple slashes " ,
266265 },
267266 {
268267 name : "invalid server name - consecutive slashes" ,
@@ -279,7 +278,7 @@ func TestPublishEndpoint(t *testing.T) {
279278 },
280279 setupRegistryService : func (_ service.RegistryService ) {},
281280 expectedStatus : http .StatusBadRequest ,
282- expectedError : "server name format is invalid: must contain exactly one slash " ,
281+ expectedError : "server name cannot contain multiple slashes " ,
283282 },
284283 {
285284 name : "invalid server name - URL-like path" ,
@@ -296,7 +295,7 @@ func TestPublishEndpoint(t *testing.T) {
296295 },
297296 setupRegistryService : func (_ service.RegistryService ) {},
298297 expectedStatus : http .StatusBadRequest ,
299- expectedError : "server name format is invalid: must contain exactly one slash " ,
298+ expectedError : "server name cannot contain multiple slashes " ,
300299 },
301300 {
302301 name : "invalid server name - many slashes" ,
@@ -313,7 +312,7 @@ func TestPublishEndpoint(t *testing.T) {
313312 },
314313 setupRegistryService : func (_ service.RegistryService ) {},
315314 expectedStatus : http .StatusBadRequest ,
316- expectedError : "server name format is invalid: must contain exactly one slash " ,
315+ expectedError : "server name cannot contain multiple slashes " ,
317316 },
318317 {
319318 name : "invalid server name - with packages and remotes" ,
@@ -351,7 +350,41 @@ func TestPublishEndpoint(t *testing.T) {
351350 },
352351 setupRegistryService : func (_ service.RegistryService ) {},
353352 expectedStatus : http .StatusBadRequest ,
354- expectedError : "server name format is invalid: must contain exactly one slash" ,
353+ expectedError : "server name cannot contain multiple slashes" ,
354+ },
355+ {
356+ name : "invalid server name - invalid namespace characters" ,
357+ requestBody : apiv0.ServerJSON {
358+ Name : "com.example@/test-server" ,
359+ Description : "Server with invalid namespace characters" ,
360+ Version : "1.0.0" ,
361+ },
362+ tokenClaims : & auth.JWTClaims {
363+ AuthMethod : auth .MethodNone ,
364+ Permissions : []auth.Permission {
365+ {Action : auth .PermissionActionPublish , ResourcePattern : "*" },
366+ },
367+ },
368+ setupRegistryService : func (_ service.RegistryService ) {},
369+ expectedStatus : http .StatusBadRequest ,
370+ expectedError : "namespace contains invalid characters" ,
371+ },
372+ {
373+ name : "invalid server name - invalid name characters" ,
374+ requestBody : apiv0.ServerJSON {
375+ Name : "com.example/test@server" ,
376+ Description : "Server with invalid name characters" ,
377+ Version : "1.0.0" ,
378+ },
379+ tokenClaims : & auth.JWTClaims {
380+ AuthMethod : auth .MethodNone ,
381+ Permissions : []auth.Permission {
382+ {Action : auth .PermissionActionPublish , ResourcePattern : "*" },
383+ },
384+ },
385+ setupRegistryService : func (_ service.RegistryService ) {},
386+ expectedStatus : http .StatusBadRequest ,
387+ expectedError : "name contains invalid characters" ,
355388 },
356389 }
357390
@@ -504,8 +537,8 @@ func TestPublishEndpoint_MultipleSlashesEdgeCases(t *testing.T) {
504537 "%s: expected status %d, got %d" , tc .description , tc .expectedStatus , rr .Code )
505538
506539 if tc .expectedStatus == http .StatusBadRequest {
507- assert .Contains (t , rr .Body .String (), "server name format is invalid: must contain exactly one slash " ,
508- "%s: should contain specific error message " , tc .description )
540+ assert .Contains (t , rr .Body .String (), "server name" ,
541+ "%s: should contain server name validation error " , tc .description )
509542 }
510543 })
511544 }
0 commit comments