Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Object> buildEvent(String domain) {
return new HashMap<>() {
Expand All @@ -33,14 +40,28 @@ 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",
"www.global.ssl.fastly.net",
"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 {
Expand Down