wscall: do not post form data by default (#23111)

This commit is contained in:
Thomas NOËL 2018-04-12 11:35:30 +02:00 committed by Frédéric Péters
parent 1588e17bf8
commit c298493c4b
2 changed files with 9 additions and 51 deletions

View File

@ -1168,6 +1168,13 @@ def test_webservice_call(http_requests, pub):
item.url = 'http://remote.example.net'
item.perform(formdata)
assert http_requests.get_last('url') == 'http://remote.example.net'
assert http_requests.get_last('method') == 'GET'
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net'
item.post = True
item.perform(formdata)
assert http_requests.get_last('url') == 'http://remote.example.net'
assert http_requests.get_last('method') == 'POST'
payload = json.loads(http_requests.get_last('body'))
assert payload['url'] == 'http://example.net/baz/%s/' % formdata.id
@ -1175,14 +1182,6 @@ def test_webservice_call(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net'
item.post = False
item.perform(formdata)
assert http_requests.get_last('url') == 'http://remote.example.net'
assert http_requests.get_last('method') == 'GET'
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net'
item.post = False
item.post_data = {'str': 'abcd', 'one': '=1', 'django': '{{ form_number }}',
'evalme': '=form_number', 'error':'=1=3'}
pub.substitutions.feed(formdata)
@ -1196,6 +1195,7 @@ def test_webservice_call(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net'
item.post = True
item.post_data = {'str': 'abcd', 'one': '=1', 'decimal': '=Decimal(2)',
'evalme': '=form_number', 'error':'=1=3'}
pub.substitutions.feed(formdata)
@ -1210,7 +1210,6 @@ def test_webservice_call(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json'
item.post = False
item.varname = 'xxx'
item.perform(formdata)
assert formdata.workflow_data['xxx_status'] == 200
@ -1220,7 +1219,6 @@ def test_webservice_call(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net'
item.post = False
item.request_signature_key = 'xxx'
item.perform(formdata)
assert 'signature=' in http_requests.get_last('url')
@ -1228,42 +1226,36 @@ def test_webservice_call(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net'
item.post = False
item.request_signature_key = '{{ doesntexist }}'
item.perform(formdata)
assert not 'signature=' in http_requests.get_last('url')
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net'
item.post = False
item.request_signature_key = '{{ empty }}'
item.perform(formdata)
assert not 'signature=' in http_requests.get_last('url')
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net'
item.post = False
item.request_signature_key = '[empty]'
item.perform(formdata)
assert not 'signature=' in http_requests.get_last('url')
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net'
item.post = False
item.request_signature_key = '{{ bar }}'
item.perform(formdata)
assert 'signature=' in http_requests.get_last('url')
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net'
item.post = False
item.request_signature_key = '[bar]'
item.perform(formdata)
assert 'signature=' in http_requests.get_last('url')
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/204'
item.post = False
item.varname = 'xxx'
item.perform(formdata)
assert formdata.workflow_data.get('xxx_status') == 204
@ -1274,7 +1266,6 @@ def test_webservice_call(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/404'
item.post = False
item.varname = 'xxx'
with pytest.raises(AbortActionException):
item.perform(formdata)
@ -1285,7 +1276,6 @@ def test_webservice_call(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/404-json'
item.post = False
item.varname = 'xxx'
with pytest.raises(AbortActionException):
item.perform(formdata)
@ -1298,26 +1288,22 @@ def test_webservice_call(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/404'
item.action_on_4xx = ':pass'
item.post = False
item.perform(formdata)
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/500'
item.post = False
with pytest.raises(AbortActionException):
item.perform(formdata)
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/500'
item.action_on_5xx = ':pass'
item.post = False
item.perform(formdata)
item = WebserviceCallStatusItem()
item.parent = st1
item.url = 'http://remote.example.net/500'
item.action_on_5xx = 'sterr' # jump to status
item.post = False
formdata.status = 'wf-st1'
formdata.store()
with pytest.raises(AbortActionException):
@ -1332,12 +1318,10 @@ def test_webservice_call(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/xml'
item.post = False
item.perform(formdata)
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/xml'
item.post = False
item.varname = 'xxx'
item.action_on_bad_data = ':stop'
with pytest.raises(AbortActionException):
@ -1349,7 +1333,6 @@ def test_webservice_call(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/404'
item.post = False
item.record_errors = True
item.action_on_4xx = ':stop'
with pytest.raises(AbortActionException):
@ -1358,7 +1341,6 @@ def test_webservice_call(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/xml'
item.post = False
item.varname = 'xxx'
item.action_on_bad_data = ':stop'
item.record_errors = True
@ -1373,7 +1355,6 @@ def test_webservice_call(http_requests, pub):
# check storing response as attachment
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/xml'
item.post = False
item.varname = 'xxx'
item.response_type = 'attachment'
item.record_errors = True
@ -1390,7 +1371,6 @@ def test_webservice_call(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/400-json'
item.post = False
item.record_errors = True
item.action_on_4xx = ':stop'
with pytest.raises(AbortActionException):
@ -1412,7 +1392,6 @@ def test_webservice_call(http_requests, pub):
item = WebserviceCallStatusItem()
item.method = 'GET'
item.post = False
item.url = 'http://remote.example.net?in_url=1'
item.qs_data = {
'str': 'abcd',
@ -1462,7 +1441,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json-err1'
item.post = False
item.action_on_app_error = ':stop'
item.action_on_4xx = ':pass'
item.action_on_5xx = ':pass'
@ -1472,7 +1450,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json-errheader1'
item.post = False
item.action_on_app_error = ':stop'
item.action_on_4xx = ':pass'
item.action_on_5xx = ':pass'
@ -1482,7 +1459,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json-errheaderstr'
item.post = False
item.action_on_app_error = ':stop'
item.action_on_4xx = ':pass'
item.action_on_5xx = ':pass'
@ -1492,7 +1468,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json-err0'
item.post = False
item.varname = 'xxx'
item.perform(formdata)
assert formdata.workflow_data['xxx_status'] == 200
@ -1503,7 +1478,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json-err0'
item.post = False
item.varname = 'xxx'
item.action_on_app_error = ':stop'
item.perform(formdata)
@ -1515,7 +1489,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json-err1'
item.post = False
item.varname = 'xxx'
item.perform(formdata)
assert formdata.workflow_data['xxx_status'] == 200
@ -1526,7 +1499,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json-errstr'
item.post = False
item.varname = 'xxx'
item.perform(formdata)
assert formdata.workflow_data['xxx_status'] == 200
@ -1537,7 +1509,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json-err1'
item.post = False
item.varname = 'xxx'
item.action_on_app_error = ':stop'
with pytest.raises(AbortActionException):
@ -1551,7 +1522,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json-errheader0'
item.post = False
item.varname = 'xxx'
item.perform(formdata)
assert formdata.workflow_data['xxx_status'] == 200
@ -1563,7 +1533,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json-errheader1'
item.post = False
item.varname = 'xxx'
item.perform(formdata)
assert formdata.workflow_data['xxx_status'] == 200
@ -1576,7 +1545,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json-errheaderstr'
item.post = False
item.varname = 'xxx'
item.perform(formdata)
assert formdata.workflow_data['xxx_status'] == 200
@ -1589,7 +1557,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json-errheader1'
item.post = False
item.varname = 'xxx'
item.action_on_app_error = ':stop'
with pytest.raises(AbortActionException):
@ -1604,7 +1571,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/xml-errheader'
item.post = False
item.varname = 'xxx'
item.response_type = 'attachment'
item.record_errors = True
@ -1617,7 +1583,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/xml-errheader'
item.post = False
item.varname = 'xxx'
item.response_type = 'attachment'
item.record_errors = True
@ -1632,7 +1597,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/xml-errheader'
item.post = False
item.varname = 'xxx'
item.response_type = 'json' # wait for json but receive xml
item.record_errors = True
@ -1645,7 +1609,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json-err1'
item.post = False
item.action_on_app_error = ':stop'
item.response_type = 'attachment' # err value is not an error
item.perform(formdata) # so, everything is "ok" here
@ -1653,7 +1616,6 @@ def test_webservice_call_error_handling(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/json-errheaderstr'
item.post = False
item.action_on_app_error = ':stop'
item.response_type = 'attachment'
with pytest.raises(AbortActionException):
@ -1663,7 +1625,6 @@ def test_webservice_call_error_handling(http_requests, pub):
# xml instead of json is not a app_error
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/xml'
item.post = False
item.varname = 'xxx'
item.action_on_app_error = ':stop'
item.action_on_4xx = ':pass'
@ -1676,7 +1637,6 @@ def test_webservice_call_error_handling(http_requests, pub):
# connection error
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/connection-error'
item.post = False
item.record_errors = True
item.action_on_network_errors = ':pass'
item.perform(formdata)
@ -1708,7 +1668,6 @@ def test_webservice_call_store_in_backoffice_filefield(http_requests, pub):
item.parent = st1
item.backoffice_filefield_id = 'bo1'
item.url = 'http://remote.example.net/xml'
item.post = False
item.varname = 'xxx'
item.response_type = 'attachment'
item.record_errors = True
@ -3080,7 +3039,6 @@ def test_set_backoffice_field_file(http_requests, two_pubs):
two_pubs.substitutions.feed(formdata)
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net/xml'
item.post = False
item.varname = 'xxx'
item.response_type = 'attachment'
item.record_errors = True

View File

@ -100,7 +100,7 @@ class WebserviceCallStatusItem(WorkflowStatusItem):
label = None
url = None
varname = None
post = True
post = False
request_signature_key = None
post_data = None
qs_data = None