Baoyuantop commented on code in PR #2766:
URL: https://github.com/apache/apisix-dashboard/pull/2766#discussion_r1136819226
##########
api/internal/core/entity/format_test.go:
##########
@@ -56,6 +56,39 @@ func TestNodesFormat(t *testing.T) {
assert.Contains(t, jsonStr, `"priority":10`)
}
+func TestNodesFormat_ipv6(t *testing.T) {
+ // route data saved in ETCD
+ routeStr := `{
+ "uris": ["/*"],
+ "upstream": {
+ "type": "roundrobin",
+ "nodes": [{
+ "host": "::1",
+ "port": 80,
+ "weight": 0,
+ "priority":10
+ }]
+ }
+ }`
+
+ // bind struct
+ var route Route
+ err := json.Unmarshal([]byte(routeStr), &route)
+ assert.Nil(t, err)
+
+ // nodes format
+ nodes := NodesFormat(route.Upstream.Nodes)
+
+ // json encode for client
+ res, err := json.Marshal(nodes)
+ assert.Nil(t, err)
+ jsonStr := string(res)
+ assert.Contains(t, jsonStr, `"weight":0`)
+ assert.Contains(t, jsonStr, `"port":80`)
+ assert.Contains(t, jsonStr, `"host":"::1"`)
Review Comment:
https://apisix.apache.org/docs/apisix/admin-api/#request-body-parameters-3
In the 'nodes' field, it is mentioned that IPv6 addresses should be enclosed
in square brackets.
--
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]