0006-toulouse_axel-zeep-upgrade-for-encoding-in-logs-3854.patch
passerelle/contrib/iparapheur/models.py | ||
---|---|---|
22 | 22 |
from django.utils.translation import ugettext_lazy as _ |
23 | 23 |
from django.http import HttpResponse, Http404 |
24 | 24 | |
25 |
from zeep import Settings |
|
25 | 26 |
from zeep.exceptions import Fault as WebFault, TransportError, XMLSyntaxError |
26 | 27 | |
27 | 28 |
from passerelle.base.models import BaseResource, HTTPResource |
... | ... | |
99 | 100 | |
100 | 101 |
def get_client(self, strict_mode=True): |
101 | 102 |
try: |
102 |
soap_client = self.soap_client(strict=strict_mode) |
|
103 |
settings = Settings(strict=strict_mode) |
|
104 |
soap_client = self.soap_client(settings=settings) |
|
103 | 105 | |
104 | 106 |
# overrides the service port address URL defined in the WSDL. |
105 | 107 |
if self.wsdl_endpoint_location: |
passerelle/contrib/toulouse_axel/models.py | ||
---|---|---|
217 | 217 |
force_text(serialized_request), |
218 | 218 |
'') # FIXME: What is the user parameter for ? |
219 | 219 | |
220 |
xml_result = ET.fromstring(result) |
|
220 |
xml_result = ET.fromstring(result.encode('utf-8'))
|
|
221 | 221 |
indent(xml_result) |
222 | 222 |
pretty_result = ET.tostring(xml_result) |
223 | 223 |
if xml_result.find('RESULTAT/STATUS').text != 'OK': |
setup.py | ||
---|---|---|
104 | 104 |
'python-dateutil', |
105 | 105 |
'Pillow', |
106 | 106 |
'jsonschema < 3.1', |
107 |
'zeep < 3.0',
|
|
107 |
'zeep >= 3.0.2',
|
|
108 | 108 |
'pycrypto', |
109 | 109 |
'unidecode', |
110 | 110 |
'paramiko', |
tests/test_iparapheur.py | ||
---|---|---|
187 | 187 |
assert (BASE_URL,) == mocked_post.call_args[0] |
188 | 188 |
assert resp.json['err'] == 1 |
189 | 189 |
assert 'zeep.exceptions.TransportError' in resp.json['err_class'] |
190 |
assert 'Server returned HTTP status 200 (<nada>)' in resp.json['err_desc'] |
|
190 |
assert 'Server returned response (200) with invalid XML' in resp.json['err_desc'] |
|
191 |
assert 'Premature end of data in tag nada' in resp.json['err_desc'] |
|
191 | 192 | |
192 | 193 |
# Unknown value for "visibility" |
193 | 194 |
err_data = data.copy() |
... | ... | |
211 | 212 |
assert (BASE_URL,) == mocked_post.call_args[0] |
212 | 213 |
assert resp.json['err'] == 1 |
213 | 214 |
assert 'zeep.exceptions.TransportError' in resp.json['err_class'] |
214 |
assert 'Server returned HTTP status 200 (<nada>)' in resp.json['err_desc'] |
|
215 |
assert 'Server returned response (200) with invalid XML' in resp.json['err_desc'] |
|
216 |
assert 'Premature end of data in tag nada' in resp.json['err_desc'] |
|
215 | 217 | |
216 | 218 |
@mock.patch('passerelle.utils.Request.get', side_effect=iph_mocked_get) |
217 | 219 |
@mock.patch('passerelle.utils.Request.post') |
... | ... | |
295 | 297 |
soap_response = """<nada>""" |
296 | 298 |
response._content = soap_response |
297 | 299 |
mocked_post.return_value = response |
298 |
#resp = app.get(url, status=500) |
|
299 | 300 |
resp = app.get(url) |
300 | 301 |
assert resp.json['err'] == 1 |
301 |
#assert 'zeep.exceptions.TransportError' in resp.json['err_class'] |
|
302 | 302 |
assert 'passerelle.utils.jsonresponse.APIError' in resp.json['err_class'] |
303 |
assert 'Server returned HTTP status 200 (<nada>)' in resp.json['err_desc'] |
|
303 |
assert 'Transport Error: Server returned response (200) with invalid XML' in resp.json['err_desc'] |
|
304 |
assert 'Premature end of data in tag nada' in resp.json['err_desc'] |
|
305 | ||
304 | 306 | |
305 | 307 |
@mock.patch('passerelle.utils.Request.get', side_effect=iph_mocked_get) |
306 | 308 |
@mock.patch('passerelle.utils.Request.post') |
307 |
- |