@@ -149,6 +149,73 @@ public void testBlockedDomainNotBlockedWhenIpBypassed() {
149149 );
150150 }
151151
152+ @ Test
153+ public void testUnicodeDomainBlockedForPunycodeRequest () {
154+ // Blocklist stores Unicode; a Punycode request for the same domain must still be blocked.
155+ ServiceConfigStore .updateFromAPIResponse (new APIResponse (
156+ true , null , 0L , null , null , null ,
157+ false , List .of (new Domain ("böse.example.com" , "block" )), true , true , List .of ()
158+ ));
159+ assertThrows (BlockedOutboundException .class , () ->
160+ DNSRecordCollector .report ("xn--bse-sna.example.com" , new InetAddress []{inetAddress1 })
161+ );
162+ }
163+
164+ @ Test
165+ public void testUnicodeDomainBlockedForUnicodeRequest () {
166+ ServiceConfigStore .updateFromAPIResponse (new APIResponse (
167+ true , null , 0L , null , null , null ,
168+ false , List .of (new Domain ("münchen.example.com" , "block" )), true , true , List .of ()
169+ ));
170+ assertThrows (BlockedOutboundException .class , () ->
171+ DNSRecordCollector .report ("münchen.example.com" , new InetAddress []{inetAddress1 })
172+ );
173+ }
174+
175+ @ Test
176+ public void testAllowedUnicodeDomainNotBlockedForPunycodeRequest () {
177+ ServiceConfigStore .updateFromAPIResponse (new APIResponse (
178+ true , null , 0L , null , null , null ,
179+ true , List .of (new Domain ("münchen-allowed.example.com" , "allow" )), true , true , List .of ()
180+ ));
181+ assertDoesNotThrow (() ->
182+ DNSRecordCollector .report ("xn--mnchen-allowed-gsb.example.com" , new InetAddress []{inetAddress1 })
183+ );
184+ }
185+
186+ @ Test
187+ public void testAllowedUnicodeDomainNotBlockedForUnicodeRequest () {
188+ ServiceConfigStore .updateFromAPIResponse (new APIResponse (
189+ true , null , 0L , null , null , null ,
190+ true , List .of (new Domain ("münchen-allowed.example.com" , "allow" )), true , true , List .of ()
191+ ));
192+ assertDoesNotThrow (() ->
193+ DNSRecordCollector .report ("münchen-allowed.example.com" , new InetAddress []{inetAddress1 })
194+ );
195+ }
196+
197+ @ Test
198+ public void testBypassedIpDoesNotRecordHostname () {
199+ BypassedContextStore .setBypassed (true );
200+ DNSRecordCollector .report ("domain1.example.com" , new InetAddress []{inetAddress1 });
201+ Hostnames .HostnameEntry [] entries = HostnamesStore .getHostnamesAsList ();
202+ assertEquals (0 , entries .length );
203+ }
204+
205+ @ Test
206+ public void testBlockedDomainStillRecordedWhenNotBypassed () {
207+ ServiceConfigStore .updateFromAPIResponse (new APIResponse (
208+ true , null , 0L , null , null , null ,
209+ false , List .of (new Domain ("blocked.example.com" , "block" )), true , true , List .of ()
210+ ));
211+ assertThrows (BlockedOutboundException .class , () ->
212+ DNSRecordCollector .report ("blocked.example.com" , new InetAddress []{inetAddress1 })
213+ );
214+ Hostnames .HostnameEntry [] entries = HostnamesStore .getHostnamesAsList ();
215+ assertEquals (1 , entries .length );
216+ assertEquals ("blocked.example.com" , entries [0 ].getHostname ());
217+ }
218+
152219 @ Test
153220 public void testUnknownDomainBlockedWhenBlockNewOutgoingRequests () {
154221 ServiceConfigStore .updateFromAPIResponse (new APIResponse (
0 commit comments