Skip to content

Commit

Permalink
Test: Added APICAST_SERVICE_FILTER_BY_URL integration test.
Browse files Browse the repository at this point in the history
This test validates that the parameter `APICAST_SERVICE_FILTER_BY_URL`
is working correctly across multiple services and the service discarding
is working correctly.

Signed-off-by: Eloy Coto <eloy.coto@gmail.com>
  • Loading branch information
eloycoto committed Apr 26, 2019
1 parent 29caca1 commit 01f8778
Showing 1 changed file with 130 additions and 0 deletions.
130 changes: 130 additions & 0 deletions t/apicast-subset-of-services.t
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,133 @@ __DATA__
["yay, api backend\n", ""]
--- error_code eval
[200, 404]



=== TEST 2: multi service configuration limited with Regexp Filter
--- env eval
("APICAST_SERVICES_FILTER_BY_URL", "^on*")
--- configuration
{
"services": [
{
"backend_version": 1,
"proxy": {
"hosts": [
"one"
],
"api_backend": "http://test:$TEST_NGINX_SERVER_PORT/",
"proxy_rules": [
{
"http_method": "GET",
"delta": 1,
"metric_system_name": "one",
"pattern": "/"
}
]
},
"id": 42
},
{
"proxy": {
"hosts": [
"two"
]
},
"id": 11
}
]
}
--- backend
location /transactions/authrep.xml {
content_by_lua_block { ngx.exit(200) }
}
--- upstream
location ~ / {
echo 'yay, api backend';
}
--- pipelined_requests eval
["GET /?user_key=1","GET /?user_key=2"]
--- more_headers eval
["Host: one", "Host: two"]
--- response_body eval
["yay, api backend\n", ""]
--- error_code eval
[200, 404]

=== TEST 3: multi service configuration limited with Regexp Filter and service list
--- env eval
(
"APICAST_SERVICES_FILTER_BY_URL", "^on*",
"APICAST_SERVICES_LIST", "21"
)
--- configuration
{
"services": [
{
"backend_version": 1,
"proxy": {
"hosts": [
"one"
],
"api_backend": "http://test:$TEST_NGINX_SERVER_PORT/",
"proxy_rules": [
{
"http_method": "GET",
"delta": 1,
"metric_system_name": "one",
"pattern": "/"
}
]
},
"id": 42
},
{
"backend_version": 1,
"proxy": {
"hosts": [
"two"
],
"api_backend": "http://test:$TEST_NGINX_SERVER_PORT/two",
"proxy_rules": [
{
"http_method": "GET",
"delta": 1,
"metric_system_name": "one",
"pattern": "/"
}
]
},
"id": 21
},
{
"proxy": {
"hosts": [
"three"
]
},
"id": 11
}
]
}
--- backend
location /transactions/authrep.xml {
content_by_lua_block { ngx.exit(200) }
}
--- upstream
location / {
echo 'yay, api backend';
}

location /two {
echo 'yay, api backend two';
}

--- pipelined_requests eval
["GET /?user_key=1","GET /?user_key=2", "GET /?user_key=3"]
--- more_headers eval
["Host: one", "Host: two", "Host: three"]
--- response_body eval
["yay, api backend\n", "yay, api backend two\n", ""]
--- error_code eval
[200, 200, 404]

0 comments on commit 01f8778

Please sign in to comment.