Skip to content

Commit

Permalink
test: replace all httpbin upstream (apache#9452)
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyDluffy6017 authored and AlinsRan committed Jun 26, 2023
1 parent 1b63f64 commit 76149b6
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 44 deletions.
2 changes: 1 addition & 1 deletion t/admin/routes4.t
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ failed to read request body: request size 1678025 is greater than the maximum si
"methods": ["GET", "GET"],
"upstream": {
"nodes": {
"httpbin.org:8080": 1,
"apisix.com:8080": 1,
"test.com:8080": 1
},
"type": "roundrobin",
Expand Down
2 changes: 1 addition & 1 deletion t/admin/upstream4.t
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ passed
ngx.HTTP_PUT,
[[{
"nodes": {
"httpbin.org:8080": 1,
"apisix.com:8080": 1,
"test.com:8080": 1
},
"type": "roundrobin",
Expand Down
12 changes: 6 additions & 6 deletions t/config-center-yaml/route-upstream.t
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,17 @@ hello world
routes:
-
id: 1
uri: /get
uri: /hello
upstream_id: 1
upstreams:
-
id: 1
nodes:
"httpbin.org:80": 1
"test.com:1980": 1
type: roundrobin
#END
--- request
GET /get
GET /hello
--- error_code: 200
Expand All @@ -161,19 +161,19 @@ GET /get
routes:
-
id: 1
uri: /get
uri: /hello
upstream_id: 1
upstreams:
-
id: 1
nodes:
"httpbin.org:80": 1
"test.com:1980": 1
type: chash
hash_on: header
key: "$aaa"
#END
--- request
GET /get
GET /hello
--- error_code: 502
--- error_log
invalid configuration: failed to match pattern
Expand Down
17 changes: 8 additions & 9 deletions t/node/merge-route.t
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ qr/merge_service_route.*"time_window":60/]
ngx.HTTP_PUT,
[[{
"upstream": {
"scheme": "https",
"scheme": "http",
"type": "roundrobin",
"nodes": {
"httpbin.org:443": 1
"test.com:1980": 1
}
}
}]]
Expand Down Expand Up @@ -266,10 +266,10 @@ passed
ngx.HTTP_PUT,
[[{
"uri": "/fake",
"host": "httpbin.org",
"host": "test.com",
"plugins": {
"proxy-rewrite": {
"uri": "/get"
"uri": "/echo"
}
},
"service_id": "1"
Expand All @@ -293,18 +293,17 @@ passed
--- request
GET /fake
--- more_headers
host: httpbin.org
--- response_body eval
qr/"Host": "httpbin.org"/
--- timeout: 5
host: test.com
--- response_headers
host: test.com



=== TEST 13: not hit route
--- request
GET /fake
--- more_headers
host: httpbin.orgxxx
host: test.comxxx
--- error_code: 404


Expand Down
6 changes: 2 additions & 4 deletions t/node/route-domain.t
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ passed
--- request
GET /echo
--- response_headers
Host: test.com
--- timeout: 10
host: test.com



Expand Down Expand Up @@ -157,8 +156,7 @@ passed
--- request
GET /echo
--- response_headers
Host: test.com:1980
--- timeout: 10
host: test.com:1980



Expand Down
6 changes: 3 additions & 3 deletions t/node/upstream-domain.t
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ qr/dns resolver domain: foo.com to \d+.\d+.\d+.\d+/
ngx.HTTP_PUT,
[[{
"nodes": {
"httpbin.orgx:80": 0
"test.comx:80": 0
},
"type": "roundrobin",
"desc": "new upstream"
Expand Down Expand Up @@ -150,8 +150,8 @@ GET /t
status: 503
status: 503
--- error_log
failed to parse domain: httpbin.orgx
failed to parse domain: httpbin.orgx
failed to parse domain: test.comx
failed to parse domain: test.comx
--- timeout: 10


Expand Down
20 changes: 10 additions & 10 deletions t/node/upstream.t
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ GET /t
ngx.HTTP_PUT,
[[{
"nodes": {
"httpbin.org:80": 1
"test.com:1980": 1
},
"type": "roundrobin",
"desc": "new upstream",
Expand Down Expand Up @@ -234,7 +234,7 @@ passed
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PUT,
[[{
"uri": "/get",
"uri": "/echo",
"upstream_id": "1"
}]]
)
Expand All @@ -254,9 +254,9 @@ passed

=== TEST 12: hit route
--- request
GET /get
--- response_body eval
qr/"Host": "httpbin.org"/
GET /echo
--- response_headers
host: test.com:1980



Expand All @@ -274,7 +274,7 @@ qr/"Host": "httpbin.org"/
"type": "roundrobin",
"desc": "new upstream",
"pass_host": "rewrite",
"upstream_host": "httpbin.org"
"upstream_host": "test.com"
}]]
)

Expand All @@ -299,7 +299,7 @@ passed
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PUT,
[[{
"uri": "/uri",
"uri": "/echo",
"upstream_id": "1"
}]]
)
Expand All @@ -319,9 +319,9 @@ passed

=== TEST 15: hit route
--- request
GET /uri
--- response_body eval
qr/host: httpbin.org/
GET /echo
--- response_headers
host: test.com



Expand Down
10 changes: 8 additions & 2 deletions t/plugin/authz-casdoor.t
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,15 @@ done
"endpoint_addr":"]] .. fake_uri .. [[",
"client_id":"7ceb9b7fda4a9061ec1c",
"client_secret":"3416238e1edf915eac08b8fe345b2b95cdba7e04"
},
"proxy-rewrite": {
"uri": "/echo"
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"httpbin.org:80": 1
"test.com:1980": 1
}
}
}]]
Expand Down Expand Up @@ -466,12 +469,15 @@ apisix:
"endpoint_addr": "http://127.0.0.1:10420",
"client_id":"7ceb9b7fda4a9061ec1c",
"client_secret":"3416238e1edf915eac08b8fe345b2b95cdba7e04"
},
"proxy-rewrite": {
"uri": "/echo"
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"httpbin.org:80": 1
"test.com:1980": 1
}
}
}]]
Expand Down
10 changes: 5 additions & 5 deletions t/plugin/jwt-auth3.t
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ hello: world
},
"upstream": {
"nodes": {
"httpbin.org:80": 1
"test.com:1980": 1
},
"type": "roundrobin"
},
"uri": "/get"
"uri": "/hello"
}]]
)
Expand All @@ -299,11 +299,11 @@ hello: world
=== TEST 12: verify (in cookie) with hiding credentials
--- request
GET /get
GET /hello
--- more_headers
Cookie: hello=world; jwt-cookie=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJ1c2VyLWtleSIsImV4cCI6MTg3OTMxODU0MX0.fNtFJnNmJgzbiYmGB0Yjvm-l6A6M4jRV1l4mnVFSYjs; foo=bar
--- response_body eval
qr/hello=world; foo=bar/
--- response_body
hello world
Expand Down
6 changes: 3 additions & 3 deletions t/plugin/proxy-mirror.t
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,8 @@ passed
[[{
"plugins": {
"proxy-mirror": {
"host": "http://httpbin.org",
"path": "/get"
"host": "http://test.com:1980",
"path": "/hello"
}
},
"upstream": {
Expand Down Expand Up @@ -736,7 +736,7 @@ GET /hello
--- response_body
hello world
--- error_log_like eval
qr/http:\/\/httpbin\.org is resolved to: http:\/\/((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/
qr/http:\/\/test\.com is resolved to: http:\/\/((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/
Expand Down

0 comments on commit 76149b6

Please sign in to comment.