def test_pivot_manager_staff_sb_get(self): # Spin up a user and run a request through the view. url = reverse("Pivoteer_Tasks") request = self.factory.get(url) request.user = Profile.objects.create_user(email='*****@*****.**', password='******', is_admin=False, is_staff=True) response = PivotManager.as_view()(request) self.assertEqual(response.status_code, 200) self.assertTrue("#SafeBrowsingPanel" in response.content.decode("utf-8")) self.assertTrue("#MalwarePanel" in response.content.decode("utf-8")) self.assertTrue("HistoricalPanel" in response.content.decode("utf-8")) self.assertTrue("#RecentPanel" in response.content.decode("utf-8"))
def test_pivot_manager_anon_get(self): # Spin up a user and run a request through the view. url = reverse("Pivoteer_Tasks") request = self.factory.get(url) request.user = AnonymousUser() response = PivotManager.as_view()(request) # Inauthenticated users should be rejected. self.assertNotEqual(response.status_code, 200) self.assertTrue("#SafeBrowsingPanel" not in response.content.decode("utf-8")) self.assertTrue("#MalwarePanel" not in response.content.decode("utf-8")) self.assertTrue("HistoricalPanel" not in response.content.decode("utf-8")) self.assertTrue("#RecentPanel" not in response.content.decode("utf-8"))
def test_pivot_manager_admin_get(self): print("calling test_pivot_manager_admin_get") # Spin up a user and run a request through the view. url = reverse("Pivoteer_Tasks") request = self.factory.get(url) request.user = Profile.objects.create_user(email='*****@*****.**', password='******', is_admin=True) response = PivotManager.as_view()(request) self.assertEqual(response.status_code, 200) self.assertTrue( "#SafeBrowsingPanel" in response.content.decode("utf-8")) self.assertTrue("#MalwarePanel" in response.content.decode("utf-8")) self.assertTrue("HistoricalPanel" in response.content.decode("utf-8")) self.assertTrue("#RecentPanel" in response.content.decode("utf-8"))
def test_pivot_manager_anon_get(self): print("calling test_pivot_manager_anon_get") # Spin up a user and run a request through the view. url = reverse("Pivoteer_Tasks") request = self.factory.get(url) request.user = AnonymousUser() response = PivotManager.as_view()(request) # Inauthenticated users should be rejected. self.assertNotEqual(response.status_code, 200) self.assertTrue( "#SafeBrowsingPanel" not in response.content.decode("utf-8")) self.assertTrue( "#MalwarePanel" not in response.content.decode("utf-8")) self.assertTrue( "HistoricalPanel" not in response.content.decode("utf-8")) self.assertTrue("#RecentPanel" not in response.content.decode("utf-8"))