+ def _validate_cas2(self, response, is_correct=True):
+ if is_correct:
+ self.assertEqual(response.status_code, 302)
+ self.assertTrue(response.has_header('location'))
+ location = urlparse(response['location'])
+ ticket = location.query.split('=')[1]
+
+ response = self.client.get(reverse('cas_service_validate'), {'ticket': ticket, 'service': self.service}, follow=False)
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.content, _cas2_sucess_response(self.username).content)
+ else:
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(len(response.context['form'].errors), 1)
+
+ response = self.client.get(reverse('cas_service_validate'), {'ticket': 'ST-12312312312312312312312', 'service': self.service}, follow=False)
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.content, _cas2_error_response(INVALID_TICKET).content)
+
+