@@ -10,10 +10,13 @@ class LocalhostFilterTest(TestCase):
1010 def apply_filter (self , data ):
1111 return self .filter_cls (self .project ).test (data )
1212
13- def get_mock_data (self , client_ip = None ):
13+ def get_mock_data (self , client_ip = None , url = None ):
1414 return {
1515 'sentry.interfaces.User' : {
1616 'ip_address' : client_ip ,
17+ },
18+ 'sentry.interfaces.Http' : {
19+ 'url' : url ,
1720 }
1821 }
1922
@@ -31,3 +34,20 @@ def test_does_not_filter_external_ip(self):
3134
3235 def test_fails_gracefully_without_user (self ):
3336 assert not self .apply_filter ({})
37+
38+ def test_filters_localhost_domain (self ):
39+ data = self .get_mock_data (url = 'http://localhost/something.html' )
40+ assert self .apply_filter (data )
41+
42+ data = self .get_mock_data (url = 'https://localhost' )
43+ assert self .apply_filter (data )
44+
45+ data = self .get_mock_data (url = 'https://127.0.0.1' )
46+ assert self .apply_filter (data )
47+
48+ def test_does_not_filter_non_localhost_domain (self ):
49+ data = self .get_mock_data (url = 'https://getsentry.com/' )
50+ assert not self .apply_filter (data )
51+
52+ data = self .get_mock_data (url = 'http://example.com/index.html?domain=localhost' )
53+ assert not self .apply_filter (data )
0 commit comments