17
17
import static org .hamcrest .Matchers .containsString ;
18
18
import static org .hamcrest .Matchers .equalTo ;
19
19
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
+ */
20
27
public class RegisteredDomainProcessorTests extends ESTestCase {
21
28
private Map <String , Object > buildEvent (String domain ) {
22
29
return new HashMap <>() {
@@ -33,14 +40,28 @@ public void testBasic() throws Exception {
33
40
testRegisteredDomainProcessor (buildEvent ("." ), null , null , null , null );
34
41
testRegisteredDomainProcessor (buildEvent ("$" ), null , null , null , null );
35
42
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 );
36
58
testRegisteredDomainProcessor (
37
59
buildEvent ("1.www.global.ssl.fastly.net" ),
38
60
"1.www.global.ssl.fastly.net" ,
39
61
"www.global.ssl.fastly.net" ,
40
62
"global.ssl.fastly.net" ,
41
63
"1"
42
64
);
43
- testRegisteredDomainProcessor (buildEvent ("www.books.amazon.co.uk" ), "www.books.amazon.co.uk" , "amazon.co.uk" , "co.uk" , "www.books" );
44
65
}
45
66
46
67
public void testUseRoot () throws Exception {
0 commit comments