juzhiyuan commented on a change in pull request #612:
URL: https://github.com/apache/apisix-dashboard/pull/612#discussion_r514888873
##########
File path: api/test/e2e/route_test.go
##########
@@ -41,126 +41,136 @@ func TestRoute_Host(t *testing.T) {
Expect().
Status(http.StatusOK)
- //sleep
- time.Sleep(time.Duration(100) * time.Millisecond)
+ //sleep
+ time.Sleep(time.Duration(100) * time.Millisecond)
//hit route -- not found
APISIXExpect(t).GET("/not_found").
Expect().
Status(http.StatusNotFound)
- //hit route -- not found, wrong host
- APISIXExpect(t).GET("/hello_").
- WithHeader("Host", "not_found.com").
- Expect().
- Status(http.StatusNotFound)
-
- //hit route - ok
- APISIXExpect(t).GET("/hello_").
- WithHeader("Host", "foo.com").
- Expect().
- Status(http.StatusOK)
-
- //create route -- invalid hosts
- MangerApiExpect(t).PUT("/apisix/admin/routes/r2").WithText(`{
- "uri": "/hello_",
- "hosts": ["$%$foo.com", "*.bar.com"],
- "upstream": {
+ //hit route -- not found, wrong host
+ APISIXExpect(t).GET("/hello_").
+ WithHeader("Host", "not_found.com").
+ Expect().
+ Status(http.StatusNotFound)
+
+ //hit route - ok
+ APISIXExpect(t).GET("/hello_").
+ WithHeader("Host", "foo.com").
+ Expect().
+ Status(http.StatusOK)
+
+ //create route -- invalid hosts
+ MangerApiExpect(t).
+ PUT("/apisix/admin/routes/r2").
+ WithText(`{
+ "uri": "/hello_",
+ "hosts": ["$%$foo.com", "*.bar.com"],
+ "upstream": {
+ "nodes": {
+ "172.16.238.120:1980": 1
+ },
+ "type": "roundrobin"
+ }
+ }`).
+ WithHeader("Authorization", accessToken).
+ Expect().
+ Status(http.StatusBadRequest)
+
+ //create route -- invalid type for hosts
+ MangerApiExpect(t).
+ PUT("/apisix/admin/routes/r2").
+ WithText(`{
+ "uri": "/hello_",
+ "hosts": [1, "*.bar.com"],
+ "upstream": {
"nodes": {
- "172.16.238.120:1980": 1
+ "172.16.238.120:1980": 1
},
"type": "roundrobin"
- }
- }`).
- WithHeader("Authorization", accessToken).
- Expect().
- Status(http.StatusBadRequest)
-
- //create route -- invalid type for hosts
- MangerApiExpect(t).PUT("/apisix/admin/routes/r2").WithText(`{
- "uri": "/hello_",
- "hosts": [1, "*.bar.com"],
- "upstream": {
- "nodes": {
- "172.16.238.120:1980": 1
- },
- "type": "roundrobin"
- }
- }`).
- WithHeader("Authorization", accessToken).
- Expect().
- //Status(http.StatusBadRequest)
- JSON().Object().ValueNotEqual("code", 0)
+ }
+ }`).
+ WithHeader("Authorization", accessToken).
Review comment:
`accessToken` is not a good name IMO, `token` would be more clearer and
without ambiguity.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]