Skip to content

Commit 975b2f5

Browse files
committed
TEST/MINOR: defaults: add tests for children defaults
1 parent 3bb4750 commit 975b2f5

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

test/configuration_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ defaults test_defaults # testing_defaults
286286
http-request allow if src 192.168.0.0/16
287287
tcp-request connection accept if TRUE
288288
tcp-request connection reject if FALSE
289+
tcp-response content accept if TRUE # my comment
290+
tcp-response content lua.foo param1 param2 if FALSE
291+
tcp-response content set-bandwidth-limit my-limit limit 1m period 10s
289292
http-response allow if src 192.168.0.0/16
290293
http-response set-header X-SSL %[ssl_fc]
291294
http-after-response set-map(map.lst) %[src] %[res.hdr(X-Value)]

test/convert.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ func StructuredToTCPResponseRuleMap() map[string]models.TCPResponseRules {
578578
res := make(map[string]models.TCPResponseRules)
579579
resources := make(map[string][]models.TCPResponseRule)
580580
_ = expectedChildResources[models.Backend](resources, "backends", "name", "tcp_response_rule_list")
581+
_ = expectedChildResources[models.Backend](resources, "defaults", "name", "tcp_response_rule_list")
581582
for k, v := range resources {
582583
res[k] = toSliceOfPtrs(v)
583584
}

test/expected/structured.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3155,6 +3155,32 @@
31553155
"type": "del-acl"
31563156
}
31573157
],
3158+
"tcp_response_rule_list": [
3159+
{
3160+
"action": "accept",
3161+
"cond": "if",
3162+
"cond_test": "TRUE",
3163+
"type": "content",
3164+
"metadata": {
3165+
"comment": "my comment"
3166+
}
3167+
},
3168+
{
3169+
"action": "lua",
3170+
"cond": "if",
3171+
"cond_test": "FALSE",
3172+
"lua_action": "foo",
3173+
"lua_params": "param1 param2",
3174+
"type": "content"
3175+
},
3176+
{
3177+
"action": "set-bandwidth-limit",
3178+
"bandwidth_limit_limit": "1m",
3179+
"bandwidth_limit_name": "my-limit",
3180+
"bandwidth_limit_period": "10s",
3181+
"type": "content"
3182+
}
3183+
],
31583184
"quic_initial_rule_list": [
31593185
{
31603186
"type": "reject"

test/structured_defaults_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,21 @@ func TestPushStructuredDefaults(t *testing.T) {
118118
Interface: "lo",
119119
},
120120
},
121+
TCPResponseRuleList: models.TCPResponseRules{
122+
&models.TCPResponseRule{
123+
Type: "content",
124+
Action: "accept",
125+
Cond: "if",
126+
CondTest: "FALSE",
127+
},
128+
},
129+
HTTPRequestRuleList: models.HTTPRequestRules{
130+
&models.HTTPRequestRule{
131+
Type: "allow",
132+
Cond: "if",
133+
CondTest: "TRUE",
134+
},
135+
},
121136
HTTPCheckList: models.HTTPChecks{
122137
&models.HTTPCheck{
123138
Type: "send-state",

0 commit comments

Comments
 (0)