def test_securedrop_can_get_most_recent_scan(self): result1 = ScanResult(live=True, hsts=True, hsts_max_age=True, securedrop=self.securedrop, landing_page_url=self.securedrop.landing_page_url) result1.save() result2 = ScanResult(live=True, hsts=False, hsts_max_age=True, securedrop=self.securedrop, landing_page_url=self.securedrop.landing_page_url) result2.save() securedrop = DirectoryEntry.objects.get(id=self.securedrop.pk) most_recent = securedrop.results.latest() self.assertEqual(most_recent.grade, 'C')
def test_save_associates_results(self): result = ScanResult( live=True, hsts=True, hsts_max_age=True, securedrop=None, landing_page_url=self.securedrop.landing_page_url, ) result.save() self.assertEqual(result.securedrop, self.securedrop)
def test_save_associates_results(self): landing_page_url = 'https://www.something.org' result = ScanResult( live=True, hsts=True, hsts_max_age=True, securedrop=None, landing_page_url=landing_page_url, ) result.save() securedrop = DirectoryEntryFactory( landing_page_url=landing_page_url, onion_address='https://notreal.onion', ) securedrop.save() result.refresh_from_db() self.assertEqual(result.securedrop, securedrop)
def test_an_instance_with_cache_control_nostore_not_set_gets_a_B(self): result = ScanResult(live=True, cache_control_nostore_set=False, hsts_max_age=True, securedrop=self.securedrop) result.save() self.assertEqual(result.grade, 'B')
def test_a_down_instance_gets_a_null_grade(self): result = ScanResult(live=False, securedrop=self.securedrop) result.save() self.assertEqual(result.grade, '?')
def test_an_instance_with_expires_not_set_gets_a_C(self): result = ScanResult(live=True, expires_set=False, securedrop=self.securedrop) result.save() self.assertEqual(result.grade, 'C')
def test_an_instance_showing_server_version_in_headers_gets_a_D(self): result = ScanResult(live=True, no_server_version=False, securedrop=self.securedrop) result.save() self.assertEqual(result.grade, 'D')
def test_an_instance_using_a_subdomain_gets_a_D(self): result = ScanResult(live=True, subdomain=True, securedrop=self.securedrop) result.save() self.assertEqual(result.grade, 'D')
def test_an_instance_using_cookies_gets_an_F(self): result = ScanResult(live=True, no_cookies=False, securedrop=self.securedrop) result.save() self.assertEqual(result.grade, 'F')
def test_grade_computed_on_save(self): result = ScanResult(live=True, hsts=True, hsts_max_age=True, securedrop=self.securedrop) self.assertEqual(result.grade, '?') result.save() self.assertEqual(result.grade, 'A')