Skip to content

Commit

Permalink
[t] cleanup test using wrong configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mikz committed Jan 12, 2017
1 parent 86a579b commit fa22794
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions t/003-apicast.t
Original file line number Diff line number Diff line change
Expand Up @@ -231,26 +231,26 @@ Two services can exist together and are split by their hostname.
require('configuration_loader').save({
services = {
{
id = 42,
id = 1,
backend_version = 1,
backend_authentication_type = 'service_token',
backend_authentication_value = 'service-one',
proxy = {
api_backend = "http://127.0.0.1:$TEST_NGINX_SERVER_PORT/api-backend/one/",
hosts = { 'one' },
backend_authentication_type = 'service_token',
backend_authentication_value = 'service-one',
proxy_rules = {
{ pattern = '/', http_method = 'GET', metric_system_name = 'hits', delta = 1 }
}
}
},
{
id = 21,
id = 2,
backend_version = 2,
backend_authentication_type = 'service_token',
backend_authentication_value = 'service-two',
proxy = {
api_backend = "http://127.0.0.1:$TEST_NGINX_SERVER_PORT/api-backend/two/",
hosts = { 'two' },
backend_authentication_type = 'service_token',
backend_authentication_value = 'service-two',
proxy_rules = {
{ pattern = '/', http_method = 'GET', metric_system_name = 'hits', delta = 2 }
}
Expand All @@ -266,7 +266,19 @@ Two services can exist together and are split by their hostname.
set $backend_endpoint 'http://127.0.0.1:$TEST_NGINX_SERVER_PORT';

location /transactions/authrep.xml {
content_by_lua_block { ngx.exit(200) }
content_by_lua_block {
if ngx.var.arg_service_id == '1' then
if ngx.var.arg_service_token == 'service-one' then
return ngx.exit(200)
end
elseif ngx.var.arg_service_id == '2' then
if ngx.var.arg_service_token == 'service-two' then
return ngx.exit(200)
end
end

ngx.exit(403)
}
}

location ~ /api-backend(/.+) {
Expand All @@ -288,12 +300,14 @@ GET /t
yay, api backend: /one/
yay, api backend: /two/
--- error_code: 200
--- no_error_log
[error]
--- grep_error_log eval: qr/apicast cache (?:hit|miss|write) key: [^,\s]+/
--- grep_error_log_out
apicast cache miss key: 42:one-key:usage[hits]=1
apicast cache write key: 42:one-key:usage[hits]=1
apicast cache miss key: 21:two-id:two-key:usage[hits]=2
apicast cache write key: 21:two-id:two-key:usage[hits]=2
apicast cache miss key: 1:one-key:usage[hits]=1
apicast cache write key: 1:one-key:usage[hits]=1
apicast cache miss key: 2:two-id:two-key:usage[hits]=2
apicast cache write key: 2:two-id:two-key:usage[hits]=2

=== TEST 7: mapping rule with fixed value is mandatory
When mapping rule has a parameter with fixed value it has to be matched.
Expand Down

0 comments on commit fa22794

Please sign in to comment.