Skip to content

Commit

Permalink
e2e test: upstream connection policy with HTTPS_PROXY camel proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
eguzki committed Feb 6, 2024
1 parent afc70d2 commit f34affb
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions t/apicast-policy-upstream-connection.t
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,86 @@ proxy request: CONNECT test-upstream.lvh.me:$TEST_NGINX_RANDOM_PORT HTTP/1.1
using proxy: $TEST_NGINX_HTTPS_PROXY
proxy_response(): timeout
--- user_files fixture=tls.pl eval
=== TEST 4: Set timeouts using HTTPS Camel proxy for backend
In this test we set some timeouts to 1s. To force a read timeout, the upstream
returns part of the response, then waits 3s (more than the timeout defined),
and after that, it returns the rest of the response. Backend is configured with https_proxy
This test uses the "ignore_response" section, because we know that the response
is not going to be complete and that makes the Test::Nginx framework raise an
error. With "ignore_response" that error is ignored.
--- configuration random_port env
{
"services": [
{
"backend_version": 1,
"proxy": {
"api_backend": "https://test-upstream.lvh.me:$TEST_NGINX_RANDOM_PORT",
"proxy_rules": [
{ "pattern": "/test", "http_method": "GET", "metric_system_name": "hits", "delta": 2 }
],
"policy_chain": [
{
"name": "apicast.policy.upstream_connection",
"configuration": {
"connect_timeout": 1,
"send_timeout": 1,
"read_timeout": 1
}
},
{
"name": "apicast.policy.camel",
"configuration": {
"https_proxy": "$TEST_NGINX_HTTPS_PROXY"
}
},
{
"name": "apicast.policy.apicast"
}
]
}
}
]
}
--- backend
location /transactions/authrep.xml {
content_by_lua_block {
ngx.exit(ngx.OK)
}
}
--- upstream env
server_name test-upstream.lvh.me;
listen $TEST_NGINX_RANDOM_PORT ssl;
ssl_certificate $TEST_NGINX_SERVER_ROOT/html/server.crt;
ssl_certificate_key $TEST_NGINX_SERVER_ROOT/html/server.key;
location /test {
content_by_lua_block {
ngx.say("first part")
ngx.flush(true)
ngx.sleep(3)
ngx.say("yay, second part")
}
access_by_lua_block {
assert = require('luassert')
assert.equal('https', ngx.var.scheme)
assert.equal('$TEST_NGINX_RANDOM_PORT', ngx.var.server_port)
assert.equal('test-upstream.lvh.me', ngx.var.ssl_server_name)
local host = ngx.req.get_headers()["Host"]
local result = string.match(host, "^test%-upstream%.lvh%.me:")
assert.equals(result, "test-upstream.lvh.me:")
}
}
--- request
GET /test?user_key=test3
--- ignore_response
--- more_headers
User-Agent: Test::APIcast::Blackbox
ETag: foobar
--- error_log env
using proxy: $TEST_NGINX_HTTPS_PROXY
err: timeout
--- user_files fixture=tls.pl eval

0 comments on commit f34affb

Please sign in to comment.