Skip to content

Commit 1504c93

Browse files
Test example.com, googleapis.com, and content-autofill.googleapis.com (#82898)
More eTLD tests for registered domain processor.
1 parent e0333f5 commit 1504c93

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
import static org.hamcrest.Matchers.containsString;
1818
import static org.hamcrest.Matchers.equalTo;
1919

20+
/**
21+
* Test parsing of an eTLD from a FQDN. The list of eTLDs is maintained here:
22+
* https://github.com/publicsuffix/list/blob/master/public_suffix_list.dat
23+
*
24+
* Effective TLDs (eTLS) are not the same as DNS TLDs. Uses for eTLDs are listed here.
25+
* https://publicsuffix.org/learn/
26+
*/
2027
public class RegisteredDomainProcessorTests extends ESTestCase {
2128
private Map<String, Object> buildEvent(String domain) {
2229
return new HashMap<>() {
@@ -33,14 +40,28 @@ public void testBasic() throws Exception {
3340
testRegisteredDomainProcessor(buildEvent("."), null, null, null, null);
3441
testRegisteredDomainProcessor(buildEvent("$"), null, null, null, null);
3542
testRegisteredDomainProcessor(buildEvent("foo.bar.baz"), null, null, null, null);
43+
testRegisteredDomainProcessor(buildEvent("www.books.amazon.co.uk"), "www.books.amazon.co.uk", "amazon.co.uk", "co.uk", "www.books");
44+
// Verify "com" is returned as the eTLD, for that FQDN or subdomain
45+
testRegisteredDomainProcessor(buildEvent("com"), "com", null, "com", null);
46+
testRegisteredDomainProcessor(buildEvent("example.com"), "example.com", "example.com", "com", null);
47+
// Verify "googleapis.com" is returned as the eTLD, for that FQDN or subdomain
48+
testRegisteredDomainProcessor(buildEvent("googleapis.com"), "googleapis.com", null, "googleapis.com", null);
49+
testRegisteredDomainProcessor(
50+
buildEvent("content-autofill.googleapis.com"),
51+
"content-autofill.googleapis.com",
52+
"content-autofill.googleapis.com",
53+
"googleapis.com",
54+
null
55+
);
56+
// Verify "global.ssl.fastly.net" is returned as the eTLD, for that FQDN or subdomain
57+
testRegisteredDomainProcessor(buildEvent("global.ssl.fastly.net"), "global.ssl.fastly.net", null, "global.ssl.fastly.net", null);
3658
testRegisteredDomainProcessor(
3759
buildEvent("1.www.global.ssl.fastly.net"),
3860
"1.www.global.ssl.fastly.net",
3961
"www.global.ssl.fastly.net",
4062
"global.ssl.fastly.net",
4163
"1"
4264
);
43-
testRegisteredDomainProcessor(buildEvent("www.books.amazon.co.uk"), "www.books.amazon.co.uk", "amazon.co.uk", "co.uk", "www.books");
4465
}
4566

4667
public void testUseRoot() throws Exception {

0 commit comments

Comments
 (0)