manirajv06 commented on code in PR #905:
URL: https://github.com/apache/yunikorn-core/pull/905#discussion_r1663994193


##########
pkg/webservice/handlers_test.go:
##########
@@ -1248,13 +1224,45 @@ func TestGetPartitionQueuesHandler(t *testing.T) {
        assertQueueInvalid(t, resp, "root.notexists!", "notexists!")
 
        // test queue is not exists
-       req, err = http.NewRequest("GET", 
"/ws/v1/partition/default/queue/root.a", strings.NewReader(""))
+       req, err = http.NewRequest("GET", partitionQueuesHandler+queueA, 
strings.NewReader(""))
        assert.NilError(t, err, "HTTP request create failed")
        req = req.WithContext(context.WithValue(req.Context(), 
httprouter.ParamsKey, httprouter.Params{httprouter.Param{Key: "partition", 
Value: "default"}, httprouter.Param{Key: "queue", Value: "notexists"}}))
        assert.NilError(t, err)
        resp = &MockResponseWriter{}
        getPartitionQueue(resp, req)
        assertQueueNotExists(t, resp)
+
+       // test queue name with special characters escaped properly
+       queueName := url.QueryEscape("root.parent.test@t#:rt:/_ff-test")
+       req, err = http.NewRequest("GET", partitionQueuesHandler+queueName, 
strings.NewReader(""))
+       assert.NilError(t, err, "HTTP request create failed")
+       req = req.WithContext(context.WithValue(req.Context(), 
httprouter.ParamsKey, httprouter.Params{
+               httprouter.Param{Key: "partition", Value: 
partitionNameWithoutClusterID},
+               httprouter.Param{Key: "queue", Value: queueName},
+       }))
+       resp = &MockResponseWriter{}
+       getPartitionQueue(resp, req)
+       assertQueueNotExists(t, resp)
+
+       // test queue name with special characters escaped not properly, catch 
error at request level
+       _, err = http.NewRequest("GET", 
partitionQueuesHandler+invalidQueueName, strings.NewReader(""))
+       assert.ErrorContains(t, err, "invalid URL escape")

Review Comment:
   Yes, am aware of it. Felt it is better to do.



-- 
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