Skip to content

Commit

Permalink
Merge pull request #547 from freedomofpress/544-remove-cookie-warning
Browse files Browse the repository at this point in the history
Remove warning from `no_cookies` scan result attribute
  • Loading branch information
harrislapiroff authored Sep 25, 2018
2 parents eaba3ab + 25d014e commit 35071bd
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 26 deletions.
2 changes: 0 additions & 2 deletions directory/models/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ class DirectoryEntry(MetadataPageMixin, Page):
)

WARNING_CHOICES = (
('no_cookies', 'Use of Cookies'),
('no_cdn', 'Use of CDN'),
('no_analytics', 'Use of Analytics'),
('subdomain', 'Subdomain'),
Expand Down Expand Up @@ -420,7 +419,6 @@ def __str__(self):

def warning_level(self, warnings_ignored=[]):
SEVERE_CONDITIONS = {
'no_cookies': False,
'no_cdn': False,
'no_analytics': False,
}
Expand Down
1 change: 0 additions & 1 deletion directory/strings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
SEVERE_WARNINGS = [
('no_cookies', '{} uses cookies.'),
('no_cdn', '{} uses a CDN.'),
('no_analytics', '{} uses analytics.'),
]
Expand Down
2 changes: 1 addition & 1 deletion directory/tests/factories/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,5 @@ class Params:
)
severe_warning = factory.Trait(
no_failures=True,
no_cookies=False,
no_analytics=False,
)
21 changes: 1 addition & 20 deletions directory/tests/test_directory_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_warning_test_absence(self):
)

def test_warning_message_suppressed_if_page_ignores_all_triggered_warnings(self):
self.entry.warnings_ignored = ['no_cookies']
self.entry.warnings_ignored = ['no_analytics']
self.entry.save()
self.entry.refresh_from_db()
response = self.client.get(self.entry.url, {'warnings': '1'})
Expand All @@ -152,22 +152,3 @@ def test_warning_message_suppressed_if_page_ignores_all_triggered_warnings(self)
'We strongly advise you to only visit this landing page <a href="https://www.torproject.org/">using the Tor browser</a>, with the <a href="https://safetydocs.example/">safety slider set to "safest"</a>.',
status_code=200,
)

def test_single_warning_message_suppressed_if_page_ignores_that_warning(self):
self.result.no_analytics = False
self.result.save()
self.entry.warnings_ignored = ['no_analytics']
self.entry.save()

response = self.client.get(self.entry.url, {'warnings': '1'})
self.assertContains(
response,
'uses cookies',
status_code=200,
)

self.assertNotContains(
response,
'uses analytics',
status_code=200,
)
4 changes: 2 additions & 2 deletions directory/tests/test_models_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def test_instance_with_unsafe_onion_addresses_gets_moderate_warning(self):
result = ScanResultFactory(safe_onion_address=False)
self.assertEqual(result.warning_level(), 'moderate')

def test_instance_with_third_party_cookies_gets_severe_warning(self):
def test_instance_with_third_party_cookies_gets_no_warning(self):
result = ScanResultFactory(no_cookies=False)
self.assertEqual(result.warning_level(), 'severe')
self.assertEqual(result.warning_level(), 'none')

def test_instance_with_analytics_gets_severe_warning(self):
result = ScanResultFactory(no_analytics=False)
Expand Down

0 comments on commit 35071bd

Please sign in to comment.