forked from 3scale/APIcast
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmanagement-policies-endpoint.t
48 lines (41 loc) · 1.03 KB
/
management-policies-endpoint.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use lib 't';
use Test::APIcast::Blackbox 'no_plan';
BEGIN {
$ENV{TEST_NGINX_MANAGEMENT_SERVER_NAME} = 'management';
}
env_to_apicast(
'APICAST_CONFIGURATION_LOADER' => 'test'
);
# Converts what's in the 'expected_json' block and the body to JSON and
# compares them. Raises and error when they do not match.
require('policies.pl');
run_tests();
__DATA__
=== TEST 1: GET /policies
Check that the endpoint returns the manifests of all the built-in policies.
--- request
GET /policies
--- more_headers
Host: management
--- response_headers
Content-Type: application/json; charset=utf-8
--- expected_json eval
use JSON;
encode_json $::policies->();
--- error_code: 200
--- no_error_log
[error]
=== TEST 2: expose only policies
APICAST_MANAGEMENT_API=policies enables the endpoint without enabling other
status info
--- env eval
(APICAST_MANAGEMENT_API => "policies")
--- request eval
["GET /policies", "GET /status/info"]
--- error_code eval
[ 200, 404]
--- expected_json eval
use JSON;
[encode_json $::policies->(), ""]
--- no_error_log
[error]