Skip to content

Commit 9cf3bad

Browse files
committed
fixed camel policy tests
1 parent 2d64484 commit 9cf3bad

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

t/apicast-policy-camel.t

+19-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ run_tests();
1010
__DATA__
1111

1212
=== TEST 1: API backend connection uses http proxy
13+
--- env eval
14+
(
15+
'BACKEND_ENDPOINT_OVERRIDE' => "http://test-backend.lvh.me:$ENV{TEST_NGINX_SERVER_PORT}"
16+
)
1317
--- configuration
1418
{
1519
"services": [
@@ -19,7 +23,7 @@ __DATA__
1923
"backend_authentication_type": "service_token",
2024
"backend_authentication_value": "token-value",
2125
"proxy": {
22-
"api_backend": "http://test:$TEST_NGINX_SERVER_PORT/",
26+
"api_backend": "http://test-upstream.lvh.me:$TEST_NGINX_SERVER_PORT/",
2327
"proxy_rules": [
2428
{ "pattern": "/", "http_method": "GET", "metric_system_name": "hits", "delta": 2 }
2529
],
@@ -39,19 +43,21 @@ __DATA__
3943
]
4044
}
4145
--- backend
46+
server_name test-backend.lvh.me;
4247
location /transactions/authrep.xml {
4348
content_by_lua_block {
4449
local expected = "service_token=token-value&service_id=42&usage%5Bhits%5D=2&user_key=value"
4550
require('luassert').same(ngx.decode_args(expected), ngx.req.get_uri_args(0))
4651
}
4752
}
4853
--- upstream
54+
server_name test-upstream.lvh.me;
4955
location / {
5056
access_by_lua_block {
5157
local host = ngx.req.get_headers()["Host"]
52-
local result = string.match(host, "^test:")
58+
local result = string.match(host, "^test%-upstream%.lvh%.me:")
5359
local assert = require('luassert')
54-
assert.equals(result, "test:")
60+
assert.equals(result, "test-upstream.lvh.me:")
5561
ngx.say("yay, api backend")
5662
}
5763
}
@@ -64,6 +70,10 @@ yay, api backend
6470
using proxy: $TEST_NGINX_HTTP_PROXY
6571

6672
=== TEST 2: API backend using all_proxy
73+
--- env eval
74+
(
75+
'BACKEND_ENDPOINT_OVERRIDE' => "http://test-backend.lvh.me:$ENV{TEST_NGINX_SERVER_PORT}"
76+
)
6777
--- configuration
6878
{
6979
"services": [
@@ -73,7 +83,7 @@ using proxy: $TEST_NGINX_HTTP_PROXY
7383
"backend_authentication_type": "service_token",
7484
"backend_authentication_value": "token-value",
7585
"proxy": {
76-
"api_backend": "http://test:$TEST_NGINX_SERVER_PORT/",
86+
"api_backend": "http://test-upstream.lvh.me:$TEST_NGINX_SERVER_PORT/",
7787
"proxy_rules": [
7888
{ "pattern": "/", "http_method": "GET", "metric_system_name": "hits", "delta": 2 }
7989
],
@@ -93,19 +103,21 @@ using proxy: $TEST_NGINX_HTTP_PROXY
93103
]
94104
}
95105
--- backend
106+
server_name test-backend.lvh.me;
96107
location /transactions/authrep.xml {
97108
content_by_lua_block {
98109
local expected = "service_token=token-value&service_id=42&usage%5Bhits%5D=2&user_key=value"
99110
require('luassert').same(ngx.decode_args(expected), ngx.req.get_uri_args(0))
100111
}
101112
}
102113
--- upstream
114+
server_name test-upstream.lvh.me;
103115
location / {
104116
access_by_lua_block {
105117
local host = ngx.req.get_headers()["Host"]
106-
local result = string.match(host, "^test:")
118+
local result = string.match(host, "^test%-upstream%.lvh%.me:")
107119
local assert = require('luassert')
108-
assert.equals(result, "test:")
120+
assert.equals(result, "test-upstream.lvh.me:")
109121
ngx.say("yay, api backend")
110122
}
111123
}
@@ -117,8 +129,7 @@ yay, api backend
117129
--- error_log env
118130
using proxy: $TEST_NGINX_HTTP_PROXY
119131

120-
121-
=== TEST 3: using HTTPS proxy for backend
132+
=== TEST 3: using HTTPS proxy for backend.
122133
--- init eval
123134
$Test::Nginx::Util::PROXY_SSL_PORT = Test::APIcast::get_random_port();
124135
$Test::Nginx::Util::ENDPOINT_SSL_PORT = Test::APIcast::get_random_port();
@@ -207,8 +218,6 @@ ETag: foobar
207218
using proxy: http://127.0.0.1:$Test::Nginx::Util::PROXY_SSL_PORT,
208219
EOF
209220

210-
211-
212221
=== TEST 4: using HTTPS proxy without api_backend upstream
213222
--- init eval
214223
$Test::Nginx::Util::PROXY_SSL_PORT = Test::APIcast::get_random_port();

0 commit comments

Comments
 (0)