-
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
Alan Moran
committed
Jan 23, 2018
1 parent
2d186bc
commit 6c515ec
Showing
1 changed file
with
91 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,91 @@ | ||
use lib 't'; | ||
use Test::APIcast::Blackbox 'no_plan'; | ||
|
||
repeat_each(1); | ||
run_tests(); | ||
|
||
__DATA__ | ||
=== TEST 1: Use maintenance mode using default values | ||
Testing 3 things: | ||
1) Check default status code | ||
2) Check default response message | ||
3) TODO - validate upstream doesn't get the request | ||
--- configuration | ||
{ | ||
"services": [ | ||
{ | ||
"id": 42, | ||
"backend_version": 1, | ||
"backend_authentication_type": "service_token", | ||
"backend_authentication_value": "token-value", | ||
"proxy": { | ||
"policy_chain": [ | ||
{ "name": "apicast.policy.maintenance_mode" }, | ||
{ "name": "apicast.policy.apicast" } | ||
], | ||
"api_backend": "http://test:$TEST_NGINX_SERVER_PORT/", | ||
"proxy_rules": [ | ||
{ "pattern": "/", "http_method": "GET", "metric_system_name": "hits", "delta": 2 } | ||
] | ||
} | ||
} | ||
] | ||
} | ||
--- upstream | ||
location / { | ||
echo 'No response from me!'; | ||
} | ||
--- request | ||
GET / | ||
--- response_body | ||
503 Service Unavailable - Maintenance | ||
--- error_code: 503 | ||
--- no_error_log | ||
[error] | ||
=== TEST 2: Use maintenance mode using custom values | ||
Testing 3 things: | ||
1) Check custom status code | ||
2) Check custom response message | ||
3) TODO - validate upstream doesn't get request | ||
--- configuration | ||
{ | ||
"services": [ | ||
{ | ||
"id": 42, | ||
"backend_version": 1, | ||
"backend_authentication_type": "service_token", | ||
"backend_authentication_value": "token-value", | ||
"proxy": { | ||
"policy_chain": [ | ||
{ "name": "apicast.policy.maintenance_mode", | ||
"configuration": { | ||
"message": "Be back soon", | ||
"status": 501 | ||
} | ||
}, | ||
{ "name": "apicast.policy.apicast" } | ||
], | ||
"api_backend": "http://test:$TEST_NGINX_SERVER_PORT/", | ||
"proxy_rules": [ | ||
{ "pattern": "/", "http_method": "GET", "metric_system_name": "hits", "delta": 2 } | ||
] | ||
} | ||
} | ||
] | ||
} | ||
--- upstream | ||
location / { | ||
echo 'No response from me!'; | ||
} | ||
--- request | ||
GET / | ||
--- response_body | ||
Be back soon | ||
--- error_code: 501 | ||
--- no_error_log | ||
[error] |