Copilot commented on code in PR #12768:
URL: https://github.com/apache/cloudstack/pull/12768#discussion_r3009544656


##########
server/src/main/java/com/cloud/template/TemplateManagerImpl.java:
##########
@@ -2416,7 +2416,7 @@ public TemplateType validateTemplateType(BaseCmd cmd, 
boolean isAdmin, boolean i
             } else if ((cmd instanceof RegisterVnfTemplateCmd || cmd 
instanceof UpdateVnfTemplateCmd) && !TemplateType.VNF.equals(templateType)) {
                 throw new InvalidParameterValueException("The template type 
must be VNF for VNF templates, but the actual type is " + templateType);
             }
-        } else if (cmd instanceof RegisterTemplateCmd) {
+        } else if (cmd instanceof RegisterTemplateCmd || cmd instanceof 
GetUploadParamsForTemplateCmd) {
             boolean isRouting = Boolean.TRUE.equals(isRoutingType);
             templateType = (cmd instanceof RegisterVnfTemplateCmd) ? 
TemplateType.VNF : (isRouting ? TemplateType.ROUTING : TemplateType.USER);
         }

Review Comment:
   `validateTemplateType` now handles `GetUploadParamsForTemplateCmd` and 
defaults the template type to USER/ROUTING when `templateType` is omitted. 
There are existing unit tests for this method in 
`server/src/test/java/com/cloud/template/TemplateManagerImplTest.java`, but 
none cover the `GetUploadParamsForTemplateCmd` path; please add tests for (1) 
default USER when neither `templateType` nor `isrouting` is provided, (2) 
default ROUTING when `isrouting=true` (admin), and (3) rejection for non-admin 
when the resolved/explicit type is not USER/VNF.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to