-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
use lib 't'; | ||
use Test::APIcast::Blackbox 'no_plan'; | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
|
||
=== TEST 1: Enables access logs when configured to do so | ||
--- configuration | ||
{ | ||
"services": [ | ||
{ | ||
"id": 42, | ||
"proxy": { | ||
"policy_chain": [ | ||
{ | ||
"name": "apicast.policy.logging", | ||
"configuration": { | ||
"enable_access_logs": true | ||
} | ||
}, | ||
{ | ||
"name": "apicast.policy.upstream", | ||
"configuration": | ||
{ | ||
"rules": [ { "regex": "/", "url": "http://echo" } ] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
--- upstream | ||
location / { | ||
content_by_lua_block { | ||
ngx.say('yay, api backend'); | ||
} | ||
} | ||
--- request | ||
GET / | ||
--- error_code: 200 | ||
--- grep_error_log eval | ||
qr/Access logs are \w+/ | ||
--- grep_error_log_out | ||
Access logs are enabled | ||
--- no_error_log | ||
[error] | ||
|
||
=== TEST 2: Disables access logs when configured to do so | ||
--- configuration | ||
{ | ||
"services": [ | ||
{ | ||
"id": 42, | ||
"proxy": { | ||
"policy_chain": [ | ||
{ | ||
"name": "apicast.policy.logging", | ||
"configuration": { | ||
"enable_access_logs": false | ||
} | ||
}, | ||
{ | ||
"name": "apicast.policy.upstream", | ||
"configuration": | ||
{ | ||
"rules": [ { "regex": "/", "url": "http://echo" } ] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
--- upstream | ||
location / { | ||
content_by_lua_block { | ||
ngx.say('yay, api backend'); | ||
} | ||
} | ||
--- request | ||
GET / | ||
--- error_code: 200 | ||
--- grep_error_log eval | ||
qr/Access logs are \w+/ | ||
--- grep_error_log_out | ||
Access logs are disabled | ||
--- no_error_log | ||
[error] | ||
|
||
=== TEST 3: Enables access logs by default when the policy is included | ||
--- configuration | ||
{ | ||
"services": [ | ||
{ | ||
"id": 42, | ||
"proxy": { | ||
"policy_chain": [ | ||
{ | ||
"name": "apicast.policy.logging", | ||
"configuration": { } | ||
}, | ||
{ | ||
"name": "apicast.policy.upstream", | ||
"configuration": | ||
{ | ||
"rules": [ { "regex": "/", "url": "http://echo" } ] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
--- upstream | ||
location / { | ||
content_by_lua_block { | ||
ngx.say('yay, api backend'); | ||
} | ||
} | ||
--- request | ||
GET / | ||
--- error_code: 200 | ||
--- grep_error_log eval | ||
qr/Access logs are \w+/ | ||
--- grep_error_log_out | ||
Access logs are enabled | ||
--- no_error_log | ||
[error] |