2
2
3
3
import org .junit .jupiter .api .Test ;
4
4
import org .junit .jupiter .params .ParameterizedTest ;
5
+ import org .junit .jupiter .params .provider .FieldSource ;
5
6
import org .junit .jupiter .params .provider .ValueSource ;
6
7
import org .logstash .Event ;
7
8
@@ -25,6 +26,12 @@ class GeoIPFilterTest {
25
26
private static final String SOURCE_FIELD = "ip" ;
26
27
private static final String TARGET_FIELD = "data" ;
27
28
29
+ // used as parameters of givenDatabaseWithCustomizedFieldWhenItsAccessedTheCustomizedIPShouldntThrowAnyErrorAndReportTheLookupAsFailure
30
+ @ SuppressWarnings ("unused" )
31
+ static Path [] databases = {MaxMindDatabases .GEOIP2_COUNTRY , MaxMindDatabases .GEOIP2_ANONYMOUS_IP ,
32
+ MaxMindDatabases .GEOIP2_ENTERPRISE , MaxMindDatabases .GEOIP2_DOMAIN , MaxMindDatabases .GEOIP2_ISP ,
33
+ MaxMindDatabases .GEOLITE2_ASN };
34
+
28
35
@ ParameterizedTest
29
36
@ ValueSource (booleans = {true , false })
30
37
void handleEventWithGeoIp2CityDatabaseShouldProperlyCreateEvent (boolean ecsEnabled ) {
@@ -266,9 +273,10 @@ void handleEventWithNoCustomFieldsShouldUseDatabasesDefaultFields() {
266
273
}
267
274
}
268
275
269
- @ Test
270
- void givenDatabaseWithCustomizedFieldWhenItsAccessedTheCustomizedIPShouldntThrowAnyErrorAndReportTheLookupAsFailure () {
271
- try (final GeoIPFilter filter = createFilter (MaxMindDatabases .GEOIP2_COUNTRY , true , Collections .emptyList ())) {
276
+ @ ParameterizedTest
277
+ @ FieldSource ("databases" )
278
+ void givenDatabaseWithCustomizedFieldWhenItsAccessedTheCustomizedIPShouldntThrowAnyErrorAndReportTheLookupAsFailure (Path geoDatabase ) {
279
+ try (final GeoIPFilter filter = createFilter (geoDatabase , true , Collections .emptyList ())) {
272
280
final RubyEvent rubyEvent = createRubyEvent ("216.160.83.60" );
273
281
assertFalse (filter .handleEvent (rubyEvent ), "Lookup of data point with invalid custom fields should report as failed" );
274
282
}
0 commit comments