@@ -10,6 +10,10 @@ run_tests();
10
10
__DATA__
11
11
12
12
=== 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
+ )
13
17
-- - configuration
14
18
{
15
19
" services" : [
@@ -19,7 +23,7 @@ __DATA__
19
23
" backend_authentication_type" : " service_token" ,
20
24
" backend_authentication_value" : " token-value" ,
21
25
" proxy" : {
22
- " api_backend" : " http://test:$ TEST_NGINX_SERVER_PORT /" ,
26
+ " api_backend" : " http://test-upstream.lvh.me :$ TEST_NGINX_SERVER_PORT /" ,
23
27
" proxy_rules" : [
24
28
{ " pattern" : " /" , " http_method" : " GET" , " metric_system_name" : " hits" , " delta" : 2 }
25
29
],
@@ -39,19 +43,21 @@ __DATA__
39
43
]
40
44
}
41
45
-- - backend
46
+ server_name test-backend. lvh. me;
42
47
location / transactions/ authrep. xml {
43
48
content_by_lua_block {
44
49
local expected = " service_token=token-value& service_id =42& usage %5Bhits%5D=2& user_key =value"
45
50
require (' luassert' ). same(ngx. decode_args(expected), ngx. req. get_uri_args(0 ))
46
51
}
47
52
}
48
53
-- - upstream
54
+ server_name test-upstream. lvh. me;
49
55
location / {
50
56
access_by_lua_block {
51
57
local host = ngx. req. get_headers()[" Host" ]
52
- local result = string. match (host, " ^test:" )
58
+ local result = string. match (host, " ^test%-upstream % . lvh % . me :" )
53
59
local assert = require (' luassert' )
54
- assert. equals(result, " test:" )
60
+ assert. equals(result, " test-upstream.lvh.me :" )
55
61
ngx. say (" yay, api backend" )
56
62
}
57
63
}
@@ -64,6 +70,10 @@ yay, api backend
64
70
using proxy: $ TEST_NGINX_HTTP_PROXY
65
71
66
72
=== 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
+ )
67
77
-- - configuration
68
78
{
69
79
" services" : [
@@ -73,7 +83,7 @@ using proxy: $TEST_NGINX_HTTP_PROXY
73
83
" backend_authentication_type" : " service_token" ,
74
84
" backend_authentication_value" : " token-value" ,
75
85
" proxy" : {
76
- " api_backend" : " http://test:$ TEST_NGINX_SERVER_PORT /" ,
86
+ " api_backend" : " http://test-upstream.lvh.me :$ TEST_NGINX_SERVER_PORT /" ,
77
87
" proxy_rules" : [
78
88
{ " pattern" : " /" , " http_method" : " GET" , " metric_system_name" : " hits" , " delta" : 2 }
79
89
],
@@ -93,19 +103,21 @@ using proxy: $TEST_NGINX_HTTP_PROXY
93
103
]
94
104
}
95
105
-- - backend
106
+ server_name test-backend. lvh. me;
96
107
location / transactions/ authrep. xml {
97
108
content_by_lua_block {
98
109
local expected = " service_token=token-value& service_id =42& usage %5Bhits%5D=2& user_key =value"
99
110
require (' luassert' ). same(ngx. decode_args(expected), ngx. req. get_uri_args(0 ))
100
111
}
101
112
}
102
113
-- - upstream
114
+ server_name test-upstream. lvh. me;
103
115
location / {
104
116
access_by_lua_block {
105
117
local host = ngx. req. get_headers()[" Host" ]
106
- local result = string. match (host, " ^test:" )
118
+ local result = string. match (host, " ^test%-upstream % . lvh % . me :" )
107
119
local assert = require (' luassert' )
108
- assert. equals(result, " test:" )
120
+ assert. equals(result, " test-upstream.lvh.me :" )
109
121
ngx. say (" yay, api backend" )
110
122
}
111
123
}
@@ -117,8 +129,7 @@ yay, api backend
117
129
-- - error_log env
118
130
using proxy: $ TEST_NGINX_HTTP_PROXY
119
131
120
-
121
- === TEST 3 : using HTTPS proxy for backend
132
+ === TEST 3 : using HTTPS proxy for backend.
122
133
-- - init eval
123
134
$ Test ::Nginx::Util::PROXY_SSL_PORT = Test ::APIcast::get_random_port();
124
135
$ Test ::Nginx::Util::ENDPOINT_SSL_PORT = Test ::APIcast::get_random_port();
@@ -207,8 +218,6 @@ ETag: foobar
207
218
using proxy: http: // 127.0 . 0. 1: $ Test ::Nginx::Util::PROXY_SSL_PORT,
208
219
EOF
209
220
210
-
211
-
212
221
=== TEST 4 : using HTTPS proxy without api_backend upstream
213
222
-- - init eval
214
223
$ Test ::Nginx::Util::PROXY_SSL_PORT = Test ::APIcast::get_random_port();
0 commit comments