@@ -24,28 +24,6 @@ import (
2424
2525const expectedTestResultSuffix = "-expected.json"
2626
27- var geoIPKeys = []string {
28- "as" ,
29- "geo" ,
30- "client.as" ,
31- "client.geo" ,
32- "destination.as" ,
33- "destination.geo" ,
34- "host.geo" , // not defined host.as in ECS
35- "observer.geo" , // not defined observer.as in ECS
36- "server.as" ,
37- "server.geo" ,
38- "source.as" ,
39- "source.geo" ,
40- "threat.enrichments.indicateor.as" ,
41- "threat.enrichments.indicateor.geo" ,
42- "threat.indicateor.as" ,
43- "threat.indicateor.geo" ,
44- // packages using geo fields in nested objects
45- "netskope.alerts.user.geo" ,
46- "netskope.events.user.geo" ,
47- }
48-
4927type testResult struct {
5028 events []json.RawMessage
5129}
@@ -69,8 +47,8 @@ func writeTestResult(testCasePath string, result *testResult, specVersion semver
6947 return nil
7048}
7149
72- func compareResults (testCasePath string , config * testConfig , result * testResult , skipGeoip bool , specVersion semver.Version ) error {
73- resultsWithoutDynamicFields , err := adjustTestResult (result , config , skipGeoip )
50+ func compareResults (testCasePath string , config * testConfig , result * testResult , specVersion semver.Version ) error {
51+ resultsWithoutDynamicFields , err := adjustTestResult (result , config )
7452 if err != nil {
7553 return fmt .Errorf ("can't adjust test results: %w" , err )
7654 }
@@ -80,7 +58,7 @@ func compareResults(testCasePath string, config *testConfig, result *testResult,
8058 return fmt .Errorf ("marshalling actual test results failed: %w" , err )
8159 }
8260
83- expectedResults , err := readExpectedTestResult (testCasePath , config , skipGeoip )
61+ expectedResults , err := readExpectedTestResult (testCasePath , config )
8462 if err != nil {
8563 return fmt .Errorf ("reading expected test result failed: %w" , err )
8664 }
@@ -161,7 +139,7 @@ func diffJson(want, got []byte, specVersion semver.Version) (string, error) {
161139 return buf .String (), err
162140}
163141
164- func readExpectedTestResult (testCasePath string , config * testConfig , skipGeoIP bool ) (* testResult , error ) {
142+ func readExpectedTestResult (testCasePath string , config * testConfig ) (* testResult , error ) {
165143 testCaseDir := filepath .Dir (testCasePath )
166144 testCaseFile := filepath .Base (testCasePath )
167145
@@ -176,15 +154,15 @@ func readExpectedTestResult(testCasePath string, config *testConfig, skipGeoIP b
176154 return nil , fmt .Errorf ("unmarshalling expected test result failed: %w" , err )
177155 }
178156
179- adjusted , err := adjustTestResult (u , config , skipGeoIP )
157+ adjusted , err := adjustTestResult (u , config )
180158 if err != nil {
181159 return nil , fmt .Errorf ("adjusting test result failed: %w" , err )
182160 }
183161 return adjusted , nil
184162}
185163
186- func adjustTestResult (result * testResult , config * testConfig , skipGeoIP bool ) (* testResult , error ) {
187- if ! skipGeoIP && ( config == nil || config .DynamicFields == nil ) {
164+ func adjustTestResult (result * testResult , config * testConfig ) (* testResult , error ) {
165+ if config == nil || config .DynamicFields == nil {
188166 return result , nil
189167 }
190168 var stripped testResult
@@ -210,15 +188,6 @@ func adjustTestResult(result *testResult, config *testConfig, skipGeoIP bool) (*
210188 }
211189 }
212190
213- if skipGeoIP {
214- for _ , key := range geoIPKeys {
215- err := m .Delete (key )
216- if err != nil && err != common .ErrKeyNotFound {
217- return nil , fmt .Errorf ("can't remove geoIP field: %w" , err )
218- }
219- }
220- }
221-
222191 b , err := json .Marshal (& m )
223192 if err != nil {
224193 return nil , fmt .Errorf ("can't marshal event: %w" , err )
0 commit comments