diff --git a/t/003-apicast.t b/t/003-apicast.t index dd6c36048..f2bf2144c 100644 --- a/t/003-apicast.t +++ b/t/003-apicast.t @@ -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 } } @@ -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(/.+) { @@ -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.