|
|
@@ -36,8 +36,8 @@ import static org.hamcrest.Matchers.nullValue;
|
|
|
public class GeoIpProcessorTests extends ESTestCase {
|
|
|
|
|
|
public void testCity() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false, "filename");
|
|
|
|
|
|
Map<String, Object> document = new HashMap<>();
|
|
|
document.put("source_field", "8.8.8.8");
|
|
|
@@ -60,8 +60,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testNullValueWithIgnoreMissing() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), true, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), true, false, "filename");
|
|
|
IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(),
|
|
|
Collections.singletonMap("source_field", null));
|
|
|
IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
|
|
|
@@ -70,8 +70,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testNonExistentWithIgnoreMissing() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), true, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), true, false, "filename");
|
|
|
IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap());
|
|
|
IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
|
|
|
processor.execute(ingestDocument);
|
|
|
@@ -79,8 +79,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testNullWithoutIgnoreMissing() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false, "filename");
|
|
|
IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(),
|
|
|
Collections.singletonMap("source_field", null));
|
|
|
IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
|
|
|
@@ -89,8 +89,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testNonExistentWithoutIgnoreMissing() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false, "filename");
|
|
|
IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap());
|
|
|
IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
|
|
|
Exception exception = expectThrows(Exception.class, () -> processor.execute(ingestDocument));
|
|
|
@@ -98,8 +98,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testCity_withIpV6() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false, "filename");
|
|
|
|
|
|
String address = "2602:306:33d3:8000::3257:9652";
|
|
|
Map<String, Object> document = new HashMap<>();
|
|
|
@@ -126,8 +126,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testCityWithMissingLocation() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false, "filename");
|
|
|
|
|
|
Map<String, Object> document = new HashMap<>();
|
|
|
document.put("source_field", "80.231.5.0");
|
|
|
@@ -142,8 +142,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testCountry() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-Country.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-Country.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false, "filename");
|
|
|
|
|
|
Map<String, Object> document = new HashMap<>();
|
|
|
document.put("source_field", "82.170.213.79");
|
|
|
@@ -161,8 +161,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testCountryWithMissingLocation() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-Country.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-Country.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false, "filename");
|
|
|
|
|
|
Map<String, Object> document = new HashMap<>();
|
|
|
document.put("source_field", "80.231.5.0");
|
|
|
@@ -178,8 +178,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
|
|
|
public void testAsn() throws Exception {
|
|
|
String ip = "82.171.64.0";
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-ASN.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-ASN.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false, "filename");
|
|
|
|
|
|
Map<String, Object> document = new HashMap<>();
|
|
|
document.put("source_field", ip);
|
|
|
@@ -197,8 +197,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testAddressIsNotInTheDatabase() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false, "filename");
|
|
|
|
|
|
Map<String, Object> document = new HashMap<>();
|
|
|
document.put("source_field", "127.0.0.1");
|
|
|
@@ -211,8 +211,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
* Don't silently do DNS lookups or anything trappy on bogus data
|
|
|
*/
|
|
|
public void testInvalid() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false, "filename");
|
|
|
|
|
|
Map<String, Object> document = new HashMap<>();
|
|
|
document.put("source_field", "www.google.com");
|
|
|
@@ -222,8 +222,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testListAllValid() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false, "filename");
|
|
|
|
|
|
Map<String, Object> document = new HashMap<>();
|
|
|
document.put("source_field", Arrays.asList("8.8.8.8", "82.171.64.0"));
|
|
|
@@ -242,8 +242,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testListPartiallyValid() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false, "filename");
|
|
|
|
|
|
Map<String, Object> document = new HashMap<>();
|
|
|
document.put("source_field", Arrays.asList("8.8.8.8", "127.0.0.1"));
|
|
|
@@ -262,8 +262,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testListNoMatches() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, false, "filename");
|
|
|
|
|
|
Map<String, Object> document = new HashMap<>();
|
|
|
document.put("source_field", Arrays.asList("127.0.0.1", "127.0.0.1"));
|
|
|
@@ -274,8 +274,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testListFirstOnly() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, true);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, true, "filename");
|
|
|
|
|
|
Map<String, Object> document = new HashMap<>();
|
|
|
document.put("source_field", Arrays.asList("8.8.8.8", "127.0.0.1"));
|
|
|
@@ -292,8 +292,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testListFirstOnlyNoMatches() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, true);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> true, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, true, "filename");
|
|
|
|
|
|
Map<String, Object> document = new HashMap<>();
|
|
|
document.put("source_field", Arrays.asList("127.0.0.1", "127.0.0.2"));
|
|
|
@@ -304,8 +304,8 @@ public class GeoIpProcessorTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testInvalidDatabase() throws Exception {
|
|
|
- GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field",
|
|
|
- loader("/GeoLite2-City.mmdb"), () -> false, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, true);
|
|
|
+ GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"),
|
|
|
+ () -> false, "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false, true, "filename");
|
|
|
|
|
|
Map<String, Object> document = new HashMap<>();
|
|
|
document.put("source_field", Arrays.asList("127.0.0.1", "127.0.0.2"));
|