Self hosted FLOSS fitness/workout, nutrition and weight tracker
Properly test iCal generation with wrong tokens
Roland Geiderfced1c7826bb
diff --git a/wger/manager/tests/test_ical.py b/wger/manager/tests/test_ical.pyindex 724262f17..a9a658761 100644--- a/wger/manager/tests/test_ical.py+++ b/wger/manager/tests/test_ical.py@@ -70,6 +70,19 @@ class WorkoutICalExportTestCase(WorkoutManagerTestCase):self.assertGreater(len(response.content), 540)self.assertLess(len(response.content), 560)+ def export_ical_token_wrong(self):+ '''+ Helper function that checks exporing an ical file using a wrong token+ '''++ uid = 'AB'+ token = 'abc-11223344556677889900'+ response = self.client.get(reverse('manager:workout:ical', kwargs={'pk': 3,+ 'uidb64': uid,+ 'token': token}))++ self.assertEqual(response.status_code, 403)+def export_ical(self, fail=False):'''Helper function@@ -96,6 +109,7 @@ class WorkoutICalExportTestCase(WorkoutManagerTestCase):self.export_ical(fail=True)self.export_ical_token()+ self.export_ical_token_wrong()def test_export_ical_owner(self):'''@@ -105,6 +119,7 @@ class WorkoutICalExportTestCase(WorkoutManagerTestCase):self.user_login('test')self.export_ical(fail=False)self.export_ical_token()+ self.export_ical_token_wrong()def test_export_ical_other(self):'''@@ -114,6 +129,7 @@ class WorkoutICalExportTestCase(WorkoutManagerTestCase):self.user_login('admin')self.export_ical(fail=True)self.export_ical_token()+ self.export_ical_token_wrong()class ScheduleICalExportTestCase(WorkoutManagerTestCase):@@ -141,6 +157,19 @@ class ScheduleICalExportTestCase(WorkoutManagerTestCase):self.assertGreater(len(response.content), 1650)self.assertLess(len(response.content), 1670)+ def export_ical_token_wrong(self):+ '''+ Helper function that checks exporing an ical file using a wrong token+ '''++ uid = 'AB'+ token = 'abc-11223344556677889900'+ response = self.client.get(reverse('manager:schedule:ical', kwargs={'pk': 2,+ 'uidb64': uid,+ 'token': token}))++ self.assertEqual(response.status_code, 403)+def export_ical(self, fail=False):'''Helper function@@ -167,6 +196,7 @@ class ScheduleICalExportTestCase(WorkoutManagerTestCase):self.export_ical(fail=True)self.export_ical_token()+ self.export_ical_token_wrong()def test_export_ical_owner(self):'''@@ -176,6 +206,7 @@ class ScheduleICalExportTestCase(WorkoutManagerTestCase):self.user_login('admin')self.export_ical(fail=False)self.export_ical_token()+ self.export_ical_token_wrong()def test_export_ical_other(self):'''@@ -185,3 +216,4 @@ class ScheduleICalExportTestCase(WorkoutManagerTestCase):self.user_login('test')self.export_ical(fail=True)self.export_ical_token()+ self.export_ical_token_wrong()