Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(filters): Filter legacy IE Mobile browsers same way as IE Desktop #7521

Merged
merged 1 commit into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/sentry/filters/legacy_browsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ def test(self, data):
if not browser['family']:
return False

# IE Desktop and IE Mobile use the same engines, therefore we can treat them as one
if browser['family'] == "IE Mobile":
browser['family'] = "IE"

# handle old style config
if opts == '1':
return self.filter_default(browser)
Expand Down
61 changes: 48 additions & 13 deletions tests/sentry/filters/test_legacy_browsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MDDC; Tablet PC 2.0)',
'ie_9':
'Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))',
'iemobile_9':
'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; NOKIA; Lumia 710)',
'ie_10':
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 7.0; InfoPath.3; .NET CLR 3.1.40767; Trident/6.0; en-IN)',
'iemobile_10':
'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)',
'opera_11':
'Opera/9.80 (Windows NT 5.1; U; it) Presto/2.7.62 Version/11.00',
'opera_12':
Expand Down Expand Up @@ -207,9 +211,7 @@ def test_does_not_filter_android_4_by_default(self):
key='filters:legacy-browsers',
value='1',
)
data = self.get_mock_data(
'Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19'
)
data = self.get_mock_data(USER_AGENTS['android_4'])
assert self.apply_filter(data) is False

def test_filters_ie_9_by_default(self):
Expand All @@ -218,7 +220,16 @@ def test_filters_ie_9_by_default(self):
key='filters:legacy-browsers',
value='1',
)
data = self.get_mock_data('Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))')
data = self.get_mock_data(USER_AGENTS['ie_9'])
assert self.apply_filter(data) is True

def test_filters_iemobile_9_by_default(self):
ProjectOption.objects.set_value(
project=self.project,
key='filters:legacy-browsers',
value='1',
)
data = self.get_mock_data(USER_AGENTS['iemobile_9'])
assert self.apply_filter(data) is True

def test_does_not_filter_ie_10_by_default(self):
Expand All @@ -230,15 +241,22 @@ def test_does_not_filter_ie_10_by_default(self):
data = self.get_mock_data(USER_AGENTS['ie_10'])
assert self.apply_filter(data) is False

def test_filters_opera_12_by_default(self):
def test_does_not_filter_iemobile_10_by_default(self):
ProjectOption.objects.set_value(
project=self.project,
key='filters:legacy-browsers',
value='1',
)
data = self.get_mock_data(
'Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16'
data = self.get_mock_data(USER_AGENTS['iemobile_10'])
assert self.apply_filter(data) is False

def test_filters_opera_12_by_default(self):
ProjectOption.objects.set_value(
project=self.project,
key='filters:legacy-browsers',
value='1',
)
data = self.get_mock_data(USER_AGENTS['opera_12'])
assert self.apply_filter(data) is True

def test_does_not_filter_chrome_by_default(self):
Expand All @@ -247,9 +265,7 @@ def test_does_not_filter_chrome_by_default(self):
key='filters:legacy-browsers',
value='1',
)
data = self.get_mock_data(
'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'
)
data = self.get_mock_data(USER_AGENTS['chrome'])
assert self.apply_filter(data) is False

def test_does_not_filter_edge_by_default(self):
Expand All @@ -258,9 +274,7 @@ def test_does_not_filter_edge_by_default(self):
key='filters:legacy-browsers',
value='1',
)
data = self.get_mock_data(
'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10136'
)
data = self.get_mock_data(USER_AGENTS['edge'])
assert self.apply_filter(data) is False

def test_filter_opera(self):
Expand Down Expand Up @@ -305,6 +319,13 @@ def test_does_filter_ie9(self):
data = self.get_mock_data(USER_AGENTS['ie_9'])
assert self.apply_filter(data) is True

def test_does_filter_iemobile_9(self):
ProjectOption.objects.set_value(
project=self.project, key='filters:legacy-browsers', value={'ie9'}
)
data = self.get_mock_data(USER_AGENTS['iemobile_9'])
assert self.apply_filter(data) is True

def test_does_filter_ie10(self):
ProjectOption.objects.set_value(
project=self.project, key='filters:legacy-browsers', value={'ie10'}
Expand All @@ -319,6 +340,20 @@ def test_does_not_filter_ie10(self):
browser = ua['user_agent']
assert self.filter_cls(self.project).filter_ie_pre_9(browser) is False

def test_does_filter_iemobile_10(self):
ProjectOption.objects.set_value(
project=self.project, key='filters:legacy-browsers', value={'ie10'}
)
data = self.get_mock_data(USER_AGENTS['iemobile_10'])
assert self.apply_filter(data) is True

def test_does_not_filter_iemobile_10(self):
data = self.get_mock_data(USER_AGENTS['iemobile_10'])
ua_data = self.filter_cls(self.project).get_user_agent(data)
ua = Parse(ua_data)
browser = ua['user_agent']
assert self.filter_cls(self.project).filter_ie_pre_9(browser) is False

def test_filters_safari(self):
ProjectOption.objects.set_value(
project=self.project, key='filters:legacy-browsers', value={'safari_pre_6'}
Expand Down