def test_saml_validation_view_invalid_service(self): """ When called with an invalid service identifier, a validation failure should be returned. """ saml = SamlValidateRequest(context={'ticket': self.st}) request = self.rf.post(build_url('cas_saml_validate', target=self.url2), saml.render_content(), content_type='text/xml') response = SamlValidateView.as_view()(request) self.assertContains(response, 'samlp:RequestDenied')
def test_saml_validation_view_http_service(self): """ When called with a non-HTTPS service identifier, a validation failure should be returned. """ saml = SamlValidateRequest(context={'ticket': self.st}) request = self.rf.post(build_url('cas_saml_validate', TARGET='http://www.example.com'), saml.render_content(), content_type='text/xml') response = SamlValidateView.as_view()(request) self.assertContains(response, 'samlp:RequestDenied')
def test_saml_validation_view_invalid_ticket(self): """ When the provided ticket cannot be found, a validation failure should be returned. """ temp_st = ServiceTicketFactory() saml = SamlValidateRequest(context={'ticket': temp_st}) temp_st.delete() request = self.rf.post(build_url('cas_saml_validate', target=self.url), saml.render_content(), content_type='text/xml') response = SamlValidateView.as_view()(request) self.assertContains(response, 'samlp:RequestDenied')
def test_saml_validation_view_invalid_ticket(self): """ When the provided ticket cannot be found, a validation failure should be returned. """ temp_st = ServiceTicketFactory() saml = SamlValidateRequest(context={'ticket': temp_st}) temp_st.delete() request = self.rf.post(build_url('cas_saml_validate', TARGET=self.st.service), saml.render_content(), content_type='text/xml') response = SamlValidateView.as_view()(request) self.assertContains(response, 'samlp:RequestDenied')
def test_saml_validation_view_success(self): """ When called with valid parameters, a validation success should be returned. The provided ticket should then be consumed. """ saml = SamlValidateRequest(context={'ticket': self.st}) request = self.rf.post(build_url('cas_saml_validate', target=self.url), saml.render_content(), content_type='text/xml') response = SamlValidateView.as_view()(request) self.assertContains(response, 'samlp:Success') st = ServiceTicket.objects.get(ticket=self.st.ticket) self.assertTrue(st.is_consumed())
def test_saml_validation_view_success(self): """ When called with valid parameters, a validation success should be returned. The provided ticket should then be consumed. """ saml = SamlValidateRequest(context={'ticket': self.st}) request = self.rf.post(build_url('cas_saml_validate', TARGET=self.st.service), saml.render_content(), content_type='text/xml') response = SamlValidateView.as_view()(request) self.assertContains(response, 'samlp:Success') st = ServiceTicket.objects.get(ticket=self.st.ticket) self.assertTrue(st.is_consumed())