diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java index f63aff0518072..f9d35b902c9d8 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java @@ -17,6 +17,13 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; +/** + * Test parsing of an eTLD from a FQDN. The list of eTLDs is maintained here: + * https://github.com/publicsuffix/list/blob/master/public_suffix_list.dat + * + * Effective TLDs (eTLS) are not the same as DNS TLDs. Uses for eTLDs are listed here. + * https://publicsuffix.org/learn/ + */ public class RegisteredDomainProcessorTests extends ESTestCase { private Map buildEvent(String domain) { return new HashMap<>() { @@ -33,6 +40,21 @@ public void testBasic() throws Exception { testRegisteredDomainProcessor(buildEvent("."), null, null, null, null); testRegisteredDomainProcessor(buildEvent("$"), null, null, null, null); testRegisteredDomainProcessor(buildEvent("foo.bar.baz"), null, null, null, null); + testRegisteredDomainProcessor(buildEvent("www.books.amazon.co.uk"), "www.books.amazon.co.uk", "amazon.co.uk", "co.uk", "www.books"); + // Verify "com" is returned as the eTLD, for that FQDN or subdomain + testRegisteredDomainProcessor(buildEvent("com"), "com", null, "com", null); + testRegisteredDomainProcessor(buildEvent("example.com"), "example.com", "example.com", "com", null); + // Verify "googleapis.com" is returned as the eTLD, for that FQDN or subdomain + testRegisteredDomainProcessor(buildEvent("googleapis.com"), "googleapis.com", null, "googleapis.com", null); + testRegisteredDomainProcessor( + buildEvent("content-autofill.googleapis.com"), + "content-autofill.googleapis.com", + "content-autofill.googleapis.com", + "googleapis.com", + null + ); + // Verify "global.ssl.fastly.net" is returned as the eTLD, for that FQDN or subdomain + testRegisteredDomainProcessor(buildEvent("global.ssl.fastly.net"), "global.ssl.fastly.net", null, "global.ssl.fastly.net", null); testRegisteredDomainProcessor( buildEvent("1.www.global.ssl.fastly.net"), "1.www.global.ssl.fastly.net", @@ -40,7 +62,6 @@ public void testBasic() throws Exception { "global.ssl.fastly.net", "1" ); - testRegisteredDomainProcessor(buildEvent("www.books.amazon.co.uk"), "www.books.amazon.co.uk", "amazon.co.uk", "co.uk", "www.books"); } public void testUseRoot() throws Exception {