soap: return 400 on unknown method name (#75626)
gitea/passerelle/pipeline/head There was a failure building this commit Details

This commit is contained in:
Thomas NOËL 2023-03-21 12:19:15 +01:00
parent b5995828a5
commit 68fe75434a
2 changed files with 16 additions and 1 deletions

View File

@ -108,7 +108,12 @@ class SOAPConnector(BaseResource, HTTPResource):
else:
return data
input_schema = self.type2schema(self.client.service._binding._operations[method_name].input.body.type)
try:
operations = self.client.service._binding._operations[method_name]
except KeyError:
raise APIError('unknown method "%s"' % method_name, http_status=400)
input_schema = self.type2schema(operations.input.body.type)
payload = {}
if input_schema and input_schema.get('type') == 'object':
properties = list(input_schema.get('properties', []))

View File

@ -335,6 +335,16 @@ def test_say_hello_method_ok_post_json(connector, app, caplog, soap):
assert resp.json == {'data': soap.OUTPUT_DATA, 'err': 0}
def test_bad_method_name_call(connector, app, caplog, soap):
resp = app.post_json('/soap/test/method/badMethodName/', params=soap.INPUT_DATA, status=400)
assert resp.json == {
'data': None,
'err': 1,
'err_class': 'passerelle.utils.jsonresponse.APIError',
'err_desc': 'unknown method "badMethodName"',
}
@pytest.mark.parametrize('soap', [SOAP12], indirect=True)
class TestAuthencation:
def test_basic_auth(self, connector, app, caplog, soap):