def test_verify_and_remove_signature_bad_reference(self, signatures_mock):
     root = Element('root')
     signature = SubElement(root, 'signature')
     child = SubElement(root, 'child')
     signatures_mock.return_value = [SignatureInfo(signature, (child, ))]
     response = SAMLResponse(ElementTree(root))
     with self.assertRaisesMessage(
             SecurityError, 'Signature does not reference parent element'):
         response._verify_and_remove_signature(signature, 'cert.pem')
     self.assertEqual(signatures_mock.mock_calls, [call(root, 'cert.pem')])
 def test_verify_and_remove_signature_not_found(self, signatures_mock):
     root = Element('root')
     signature = SubElement(root, 'signature')
     SubElement(root, 'child')
     signatures_mock.return_value = [SignatureInfo(signature, (root, ))]
     response = SAMLResponse(ElementTree(root))
     with self.assertRaisesMessage(SecurityError, 'Signature not found'):
         response._verify_and_remove_signature(Element('signature2'),
                                               'cert.pem')
     self.assertEqual(signatures_mock.mock_calls, [call(root, 'cert.pem')])