@@ -710,25 +710,30 @@ func TestCreateServers(t *testing.T) {
710
710
{
711
711
Name : "Version" ,
712
712
Value : "V1" ,
713
+ Type : dataplane .MatchTypeExact ,
713
714
},
714
715
{
715
716
Name : "test" ,
716
717
Value : "foo" ,
718
+ Type : dataplane .MatchTypeExact ,
717
719
},
718
720
{
719
721
Name : "my-header" ,
720
722
Value : "my-value" ,
723
+ Type : dataplane .MatchTypeExact ,
721
724
},
722
725
},
723
726
QueryParams : []dataplane.HTTPQueryParamMatch {
724
727
{
725
728
// query names and values should not be normalized to lowercase
726
729
Name : "GrEat" ,
727
730
Value : "EXAMPLE" ,
731
+ Type : dataplane .MatchTypeExact ,
728
732
},
729
733
{
730
734
Name : "test" ,
731
735
Value : "foo=bar" ,
736
+ Type : dataplane .MatchTypeExact ,
732
737
},
733
738
},
734
739
},
@@ -797,6 +802,7 @@ func TestCreateServers(t *testing.T) {
797
802
{
798
803
Name : "redirect" ,
799
804
Value : "this" ,
805
+ Type : dataplane .MatchTypeExact ,
800
806
},
801
807
},
802
808
},
@@ -839,6 +845,7 @@ func TestCreateServers(t *testing.T) {
839
845
{
840
846
Name : "rewrite" ,
841
847
Value : "this" ,
848
+ Type : dataplane .MatchTypeExact ,
842
849
},
843
850
},
844
851
},
@@ -878,6 +885,7 @@ func TestCreateServers(t *testing.T) {
878
885
{
879
886
Name : "filter" ,
880
887
Value : "this" ,
888
+ Type : dataplane .MatchTypeExact ,
881
889
},
882
890
},
883
891
},
@@ -1071,23 +1079,23 @@ func TestCreateServers(t *testing.T) {
1071
1079
"1_1" : {
1072
1080
{
1073
1081
Method : "GET" ,
1074
- Headers : []string {"Version:V1" , "test:foo" , "my-header:my-value" },
1075
- QueryParams : []string {"GrEat=EXAMPLE" , "test=foo=bar" },
1082
+ Headers : []string {"Version:Exact: V1" , "test:Exact: foo" , "my-header:Exact :my-value" },
1083
+ QueryParams : []string {"GrEat=Exact= EXAMPLE" , "test=Exact =foo=bar" },
1076
1084
RedirectPath : "/_ngf-internal-rule1-route0" ,
1077
1085
},
1078
1086
},
1079
1087
"1_6" : {
1080
- {RedirectPath : "/_ngf-internal-rule6-route0" , Headers : []string {"redirect:this" }},
1088
+ {RedirectPath : "/_ngf-internal-rule6-route0" , Headers : []string {"redirect:Exact: this" }},
1081
1089
},
1082
1090
"1_8" : {
1083
1091
{
1084
- Headers : []string {"rewrite:this" },
1092
+ Headers : []string {"rewrite:Exact: this" },
1085
1093
RedirectPath : "/_ngf-internal-rule8-route0" ,
1086
1094
},
1087
1095
},
1088
1096
"1_10" : {
1089
1097
{
1090
- Headers : []string {"filter:this" },
1098
+ Headers : []string {"filter:Exact: this" },
1091
1099
RedirectPath : "/_ngf-internal-rule10-route0" ,
1092
1100
},
1093
1101
},
@@ -2702,14 +2710,17 @@ func TestCreateRouteMatch(t *testing.T) {
2702
2710
{
2703
2711
Name : "header-1" ,
2704
2712
Value : "val-1" ,
2713
+ Type : dataplane .MatchTypeExact ,
2705
2714
},
2706
2715
{
2707
2716
Name : "header-2" ,
2708
2717
Value : "val-2" ,
2718
+ Type : dataplane .MatchTypeExact ,
2709
2719
},
2710
2720
{
2711
2721
Name : "header-3" ,
2712
2722
Value : "val-3" ,
2723
+ Type : dataplane .MatchTypeExact ,
2713
2724
},
2714
2725
}
2715
2726
@@ -2725,19 +2736,22 @@ func TestCreateRouteMatch(t *testing.T) {
2725
2736
{
2726
2737
Name : "arg1" ,
2727
2738
Value : "val1" ,
2739
+ Type : dataplane .MatchTypeExact ,
2728
2740
},
2729
2741
{
2730
2742
Name : "arg2" ,
2731
2743
Value : "val2=another-val" ,
2744
+ Type : dataplane .MatchTypeExact ,
2732
2745
},
2733
2746
{
2734
2747
Name : "arg3" ,
2735
2748
Value : "==val3" ,
2749
+ Type : dataplane .MatchTypeExact ,
2736
2750
},
2737
2751
}
2738
2752
2739
- expectedHeaders := []string {"header-1:val-1" , "header-2:val-2" , "header-3:val-3" }
2740
- expectedArgs := []string {"arg1=val1" , "arg2=val2=another-val" , "arg3===val3" }
2753
+ expectedHeaders := []string {"header-1:Exact: val-1" , "header-2:Exact: val-2" , "header-3:Exact :val-3" }
2754
+ expectedArgs := []string {"arg1=Exact= val1" , "arg2=Exact= val2=another-val" , "arg3=Exact ===val3" }
2741
2755
2742
2756
tests := []struct {
2743
2757
match dataplane.Match
@@ -2856,41 +2870,74 @@ func TestCreateRouteMatch(t *testing.T) {
2856
2870
2857
2871
func TestCreateQueryParamKeyValString (t * testing.T ) {
2858
2872
t .Parallel ()
2859
- g := NewWithT (t )
2860
-
2861
- expected := "key=value"
2862
2873
2863
- result := createQueryParamKeyValString (
2864
- dataplane.HTTPQueryParamMatch {
2865
- Name : "key" ,
2866
- Value : "value" ,
2874
+ tests := []struct {
2875
+ msg string
2876
+ input dataplane.HTTPQueryParamMatch
2877
+ expected string
2878
+ }{
2879
+ {
2880
+ msg : "Exact match" ,
2881
+ input : dataplane.HTTPQueryParamMatch {
2882
+ Name : "key" ,
2883
+ Value : "value" ,
2884
+ Type : dataplane .MatchTypeExact ,
2885
+ },
2886
+ expected : "key=Exact=value" ,
2867
2887
},
2868
- )
2869
-
2870
- g .Expect (result ).To (Equal (expected ))
2871
-
2872
- expected = "KeY=vaLUe=="
2873
-
2874
- result = createQueryParamKeyValString (
2875
- dataplane.HTTPQueryParamMatch {
2876
- Name : "KeY" ,
2877
- Value : "vaLUe==" ,
2888
+ {
2889
+ msg : "RegularExpression match" ,
2890
+ input : dataplane.HTTPQueryParamMatch {
2891
+ Name : "KeY" ,
2892
+ Value : "vaLUe-[a-z]==" ,
2893
+ Type : dataplane .MatchTypeRegularExpression ,
2894
+ },
2895
+ expected : "KeY=RegularExpression=vaLUe-[a-z]==" ,
2878
2896
},
2879
- )
2897
+ {
2898
+ msg : "empty match type" ,
2899
+ input : dataplane.HTTPQueryParamMatch {
2900
+ Name : "keY" ,
2901
+ Value : "vaLUe==" ,
2902
+ Type : dataplane .MatchTypeExact ,
2903
+ },
2904
+ expected : "keY=Exact=vaLUe==" ,
2905
+ },
2906
+ }
2880
2907
2881
- g .Expect (result ).To (Equal (expected ))
2908
+ for _ , tc := range tests {
2909
+ t .Run (tc .msg , func (t * testing.T ) {
2910
+ t .Parallel ()
2911
+ g := NewWithT (t )
2912
+ result := createQueryParamKeyValString (tc .input )
2913
+ g .Expect (result ).To (Equal (tc .expected ))
2914
+ })
2915
+ }
2882
2916
}
2883
2917
2884
2918
func TestCreateHeaderKeyValString (t * testing.T ) {
2885
2919
t .Parallel ()
2886
2920
g := NewWithT (t )
2887
2921
2888
- expected := "kEy:vALUe"
2922
+ expected := "kEy:Exact: vALUe"
2889
2923
2890
2924
result := createHeaderKeyValString (
2891
2925
dataplane.HTTPHeaderMatch {
2892
2926
Name : "kEy" ,
2893
2927
Value : "vALUe" ,
2928
+ Type : dataplane .MatchTypeExact ,
2929
+ },
2930
+ )
2931
+
2932
+ g .Expect (result ).To (Equal (expected ))
2933
+
2934
+ expected = "kEy:RegularExpression:vALUe-[0-9]"
2935
+
2936
+ result = createHeaderKeyValString (
2937
+ dataplane.HTTPHeaderMatch {
2938
+ Name : "kEy" ,
2939
+ Value : "vALUe-[0-9]" ,
2940
+ Type : dataplane .MatchTypeRegularExpression ,
2894
2941
},
2895
2942
)
2896
2943
0 commit comments