forked from 3scale/APIcast
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathliquid.t
69 lines (63 loc) · 1.56 KB
/
liquid.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use lib 't';
use Test::APIcast::Blackbox 'no_plan';
# Parsing only occurs when loading the config, so we will only see the Liquid
# error in the first request.
repeat_each(1);
run_tests();
__DATA__
=== TEST 1: invalid liquid in the config
When there is an invalid Liquid in the config, APIcast:
1) Does not crash.
2) Shows an error.
3) Evaluates the invalid Liquid as and empty string (Notice the arg added by
the URL rewriting policy in the response.
--- configuration
{
"services": [
{
"id": 42,
"proxy": {
"policy_chain": [
{
"name": "apicast.policy.url_rewriting",
"configuration": {
"query_args_commands": [
{
"op": "set",
"arg": "new_arg",
"value": "{{'something' | md5",
"value_type": "liquid"
}
]
}
},
{
"name": "apicast.policy.upstream",
"configuration": {
"rules": [
{
"regex": "/",
"url": "http://test:$TEST_NGINX_SERVER_PORT"
}
]
}
}
]
}
}
]
}
--- upstream
location / {
content_by_lua_block {
local luassert = require('luassert')
-- Verify here that the new arg was set to empty
luassert.equals('', ngx.req.get_uri_args()['new_arg'])
ngx.say('yay, api backend')
}
}
--- request
GET /
--- error_code: 200
--- error_log
Invalid Liquid: {{'something' | md5