Skip to content

Commit 6357454

Browse files
committed
BUG/MINOR: accept set-var-fmt in http_request_rule
1 parent ad3392b commit 6357454

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

configuration/configuration_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ frontend test
420420
http-request track-sc2 src table tr2 if TRUE
421421
http-request track-sc5 src table test if TRUE
422422
http-request sc-set-gpt(1,2) hdr(Host),lower if FALSE
423+
http-request set-var-fmt(txn.from) %[src]:%[src_port]
423424
http-response allow if src 192.168.0.0/16
424425
http-response set-header X-SSL %[ssl_fc]
425426
http-response set-var(req.my_var) req.fhdr(user-agent),lower

configuration/http_request_rule_test.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ func TestGetHTTPRequestRules(t *testing.T) { //nolint:gocognit,gocyclo
3030
t.Error(err.Error())
3131
}
3232

33-
if len(hRules) != 48 {
34-
t.Errorf("%v http request rules returned, expected 48", len(hRules))
33+
if len(hRules) != 49 {
34+
t.Errorf("%v http request rules returned, expected 49", len(hRules))
3535
}
3636

3737
if v != version {
@@ -745,6 +745,19 @@ func TestGetHTTPRequestRules(t *testing.T) { //nolint:gocognit,gocyclo
745745
if r.ScIdx != 2 {
746746
t.Errorf("%v: sc-idx not 2: %v", *r.Index, r.ScIdx)
747747
}
748+
case 48:
749+
if r.Type != "set-var-fmt" {
750+
t.Errorf("%v: Type not set-var-fmt: %v", *r.Index, r.Type)
751+
}
752+
if r.VarName != "from" {
753+
t.Errorf("%v: VarName not from: %v", *r.Index, r.VarName)
754+
}
755+
if r.VarFormat != "%[src]:%[src_port]" {
756+
t.Errorf("%v: VarFormat not %%[src]:%%[src_port]: %v", *r.Index, r.VarFormat)
757+
}
758+
if r.VarScope != "txn" {
759+
t.Errorf("%v: VarScope not txn: %v", *r.Index, r.VarScope)
760+
}
748761
default:
749762
t.Errorf("Expect only http-request 0 to 47, %v found", *r.Index)
750763
}
@@ -919,9 +932,9 @@ func TestCreateEditDeleteHTTPRequestRule(t *testing.T) {
919932
t.Error("Version not incremented")
920933
}
921934

922-
_, _, err = clientTest.GetHTTPRequestRule(48, "frontend", "test", "")
935+
_, _, err = clientTest.GetHTTPRequestRule(49, "frontend", "test", "")
923936
if err == nil {
924-
t.Error("DeleteHTTPRequestRule failed, HTTP Request Rule 48 still exists")
937+
t.Error("DeleteHTTPRequestRule failed, HTTP Request Rule 49 still exists")
925938
}
926939

927940
err = clientTest.DeleteHTTPRequestRule(2, "backend", "test_2", "", version)

models/http_request_rule.go

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/build/haproxy_spec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4424,6 +4424,7 @@ definitions:
44244424
- set-tos
44254425
- set-uri
44264426
- set-var
4427+
- set-var-fmt
44274428
- silent-drop
44284429
- strict-mode
44294430
- tarpit

specification/models/configuration/http/request.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ http_request_rule:
6262
- set-tos
6363
- set-uri
6464
- set-var
65+
- set-var-fmt
6566
- silent-drop
6667
- strict-mode
6768
- tarpit

0 commit comments

Comments
 (0)