Skip to content

Commit c455fdb

Browse files
authored
fix: ignore top-level RegexValues mirrored by AWS in DescribeRules response (#4749)
1 parent e9339ce commit c455fdb

2 files changed

Lines changed: 55 additions & 1 deletion

File tree

pkg/equality/elbv2/compare_option_for_rule_conditions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func CompareOptionForRuleCondition() cmp.Option {
1717
cmpopts.IgnoreUnexported(elbv2types.QueryStringConditionConfig{}),
1818
cmpopts.IgnoreUnexported(elbv2types.QueryStringKeyValuePair{}),
1919
cmpopts.IgnoreUnexported(elbv2types.SourceIpConditionConfig{}),
20-
cmpopts.IgnoreFields(elbv2types.RuleCondition{}, "Values"),
20+
cmpopts.IgnoreFields(elbv2types.RuleCondition{}, "Values", "RegexValues"),
2121
}
2222
}
2323

pkg/equality/elbv2/compare_option_for_rule_conditions_test.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,60 @@ func Test_CompareOptionForRuleConditions(t *testing.T) {
7979
},
8080
expected: true,
8181
},
82+
{
83+
name: "equal - regex path pattern with AWS-mirrored top-level RegexValues",
84+
desiredRuleCondition: []types.RuleCondition{
85+
{
86+
Field: awssdk.String("host-header"),
87+
HostHeaderConfig: &types.HostHeaderConditionConfig{
88+
Values: []string{"example.com"},
89+
},
90+
},
91+
{
92+
Field: awssdk.String("path-pattern"),
93+
PathPatternConfig: &types.PathPatternConditionConfig{
94+
RegexValues: []string{"^/api/v1/.*"},
95+
},
96+
},
97+
},
98+
actualRuleCondition: []types.RuleCondition{
99+
{
100+
Field: awssdk.String("host-header"),
101+
HostHeaderConfig: &types.HostHeaderConditionConfig{
102+
Values: []string{"example.com"},
103+
},
104+
},
105+
{
106+
Field: awssdk.String("path-pattern"),
107+
PathPatternConfig: &types.PathPatternConditionConfig{
108+
RegexValues: []string{"^/api/v1/.*"},
109+
},
110+
RegexValues: []string{"^/api/v1/.*"},
111+
},
112+
},
113+
expected: true,
114+
},
115+
{
116+
name: "not equal - different regex path pattern",
117+
desiredRuleCondition: []types.RuleCondition{
118+
{
119+
Field: awssdk.String("path-pattern"),
120+
PathPatternConfig: &types.PathPatternConditionConfig{
121+
RegexValues: []string{"^/api/v1/.*"},
122+
},
123+
},
124+
},
125+
actualRuleCondition: []types.RuleCondition{
126+
{
127+
Field: awssdk.String("path-pattern"),
128+
PathPatternConfig: &types.PathPatternConditionConfig{
129+
RegexValues: []string{"^/api/v2/.*"},
130+
},
131+
RegexValues: []string{"^/api/v2/.*"},
132+
},
133+
},
134+
expected: false,
135+
},
82136
}
83137

84138
for _, tc := range testCase {

0 commit comments

Comments
 (0)