Skip to content

Commit 5e2ba42

Browse files
committed
fix: Fix accesslog control test assertions
The test was incorrectly comparing the entire AccessLogFilter struct when it should only be comparing the masked query parameters map. This change updates the test to correctly access the masked query parameters from the state bag and compare only that specific field. Signed-off-by: Aleksandr Ponimaskin <[email protected]>
1 parent b83e48c commit 5e2ba42

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: filters/accesslog/control_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestAccessLogMaskedParametersMerging(t *testing.T) {
9999
msg string
100100
state filters.Spec
101101
args [][]any
102-
result AccessLogFilter
102+
result map[string]struct{}
103103
}{
104104
{
105105
msg: "should merge masked query params from multiple filters",
@@ -108,7 +108,7 @@ func TestAccessLogMaskedParametersMerging(t *testing.T) {
108108
{"key_1"},
109109
{"key_2"},
110110
},
111-
result: AccessLogFilter{Enable: true, MaskedQueryParams: map[string]struct{}{"key_1": {}, "key_2": {}}},
111+
result: map[string]struct{}{"key_1": {}, "key_2": {}},
112112
},
113113
{
114114
msg: "should overwrite already masked params",
@@ -118,7 +118,7 @@ func TestAccessLogMaskedParametersMerging(t *testing.T) {
118118
{"key_1"},
119119
{"key_1"},
120120
},
121-
result: AccessLogFilter{Enable: true, MaskedQueryParams: map[string]struct{}{"key_1": {}}},
121+
result: map[string]struct{}{"key_1": {}},
122122
},
123123
} {
124124
t.Run(ti.msg, func(t *testing.T) {
@@ -138,8 +138,8 @@ func TestAccessLogMaskedParametersMerging(t *testing.T) {
138138
}
139139

140140
bag := ctx.StateBag()
141-
filter := bag[AccessLogEnabledKey]
142-
assert.Equal(t, filter, &ti.result, "access log state is not equal to expected")
141+
params := bag[AccessLogAdditionalDataKey].(map[string]interface{})[KeyMaskedQueryParams].(map[string]struct{})
142+
assert.Equal(t, params, ti.result, "access log state is not equal to expected")
143143
})
144144
}
145145
}

0 commit comments

Comments
 (0)