+ def test_successful_login_with_proxy(self):
+ urllib2.urlopen = dummy_urlopen # monkey patching urllib2.urlopen so that the testcase doesnt really opens a url
+ proxyTarget = "http://my.sweet.service"
+
+ response = self._login_user('root', '123')
+ response = self._validate_cas2(response, True, proxyTarget )
+
+ # Test: I'm acting as the service that will call another service
+ # Step 1: Get the proxy granting ticket
+ responseXml = ElementTree.parse(StringIO.StringIO(response.content))
+ auth_success = responseXml.find(CAS + 'authenticationSuccess', namespaces=NSMAP)
+ pgt = auth_success.find(CAS + "proxyGrantingTicket", namespaces=NSMAP)
+ user = auth_success.find(CAS + "user", namespaces=NSMAP)
+ self.assertEqual('root', user.text)
+ self.assertIsNotNone(pgt.text)
+ self.assertTrue(pgt.text.startswith('PGTIOU'))
+
+ #Step 2: Get the actual proxy ticket
+ proxyTicketResponse = self.client.get(reverse('proxy'), {'targetService': proxyTarget, 'pgt': pgt.text}, follow=False)
+ proxyTicketResponseXml = ElementTree.parse(StringIO.StringIO(proxyTicketResponse.content))
+ self.assertIsNotNone(proxyTicketResponseXml.find(CAS + "proxySuccess", namespaces=NSMAP))
+ self.assertIsNotNone(proxyTicketResponseXml.find(CAS + "proxySuccess/cas:proxyTicket", namespaces=NSMAP))
+ proxyTicket = proxyTicketResponseXml.find(CAS + "proxySuccess/cas:proxyTicket", namespaces=NSMAP);
+
+ #Step 3: I have the proxy ticket I can talk to some other backend service as the currently logged in user!
+ proxyValidateResponse = self.client.get(reverse('cas_proxy_validate'), {'ticket': proxyTicket.text, 'service': proxyTarget, 'pgtUrl': None})
+ proxyValidateResponseXml = ElementTree.parse(StringIO.StringIO(proxyValidateResponse.content))
+
+ auth_success_2 = proxyValidateResponseXml.find(CAS + 'authenticationSuccess', namespaces=NSMAP)
+ user_2 = auth_success.find(CAS + "user", namespaces=NSMAP)
+ proxies = auth_success.find(CAS + "proxies")
+ self.assertIsNotNone(auth_success_2)
+ self.assertEqual(user.text, user_2.text)
+ self.assertIsNotNone(proxies)
+
+
+ def test_successful_proxy_chaining(self):
+ self.assertFalse(True)
+
+ def test_successful_service_not_matching_in_request_to_proxy(self):
+ self.assertFalse(True)
+
+