soap: do not check wsdl url if certificates are changed (#77923)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
The request wrapper needs a filepath to the certificates and Django cannot provide one during the clean method.
This commit is contained in:
parent
dcb772fdbd
commit
62ed945d62
|
@ -52,10 +52,13 @@ class SOAPConnector(BaseResource, HTTPResource):
|
||||||
verbose_name = _('SOAP connector')
|
verbose_name = _('SOAP connector')
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
try:
|
if (not self.client_certificate or self.client_certificate._committed) and (
|
||||||
self.operations_and_schemas
|
not self.trusted_certificate_authorities or self.trusted_certificate_authorities._committed
|
||||||
except Exception as e:
|
):
|
||||||
raise ValidationError(e)
|
try:
|
||||||
|
self.operations_and_schemas
|
||||||
|
except Exception as e:
|
||||||
|
raise ValidationError(e)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_manager_form_class(cls, **kwargs):
|
def get_manager_form_class(cls, **kwargs):
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIC6jCCAlOgAwIBAgIUe6FTOqFgqWRGMcAYv/OvZtPBgLYwDQYJKoZIhvcNAQEL
|
||||||
|
BQAwgYYxCzAJBgNVBAYTAlhYMRIwEAYDVQQIDAlTdGF0ZU5hbWUxETAPBgNVBAcM
|
||||||
|
CENpdHlOYW1lMRQwEgYDVQQKDAtDb21wYW55TmFtZTEbMBkGA1UECwwSQ29tcGFu
|
||||||
|
eVNlY3Rpb25OYW1lMR0wGwYDVQQDDBRDb21tb25OYW1lT3JIb3N0bmFtZTAeFw0y
|
||||||
|
MzA1MjUxNDU4NDFaFw0zMzA1MjIxNDU4NDFaMIGGMQswCQYDVQQGEwJYWDESMBAG
|
||||||
|
A1UECAwJU3RhdGVOYW1lMREwDwYDVQQHDAhDaXR5TmFtZTEUMBIGA1UECgwLQ29t
|
||||||
|
cGFueU5hbWUxGzAZBgNVBAsMEkNvbXBhbnlTZWN0aW9uTmFtZTEdMBsGA1UEAwwU
|
||||||
|
Q29tbW9uTmFtZU9ySG9zdG5hbWUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB
|
||||||
|
AMSkMiZUdRRaI9jh3naKGjSHTEtO38TOEry87WKdb4mkJEXKPtgVVpIYbi2f2l0/
|
||||||
|
kmUMMd3hF7Fos6DedbFTrJu50CC7wGAdjv8+9DO0WiIEWyjDERhwewqtWS/pcinE
|
||||||
|
CPrQfGBV1IqBLUTggDSigVFdMFe24G7yZtEuax/8U3enAgMBAAGjUzBRMB0GA1Ud
|
||||||
|
DgQWBBTbNks+EQxBIrAttpPa8CqnW7/s0TAfBgNVHSMEGDAWgBTbNks+EQxBIrAt
|
||||||
|
tpPa8CqnW7/s0TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4GBAFXf
|
||||||
|
SwGh173QWUOds/Nc+ZP0ybkwetVzCQzd0bl60YQI/DBL2729tTYOSdKYIdC1ooOQ
|
||||||
|
V4/sRPy4/5ztRUGQl52fuwEQAftORDfnH50Vr2lrfauX+xEOr97HvpYmkG3ivLL2
|
||||||
|
bk3urdjrkij/f5ROYKTWPY7nQAZchECgrHue7u6u
|
||||||
|
-----END CERTIFICATE-----
|
|
@ -17,6 +17,7 @@ import base64
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from webtest import Upload
|
||||||
|
|
||||||
from passerelle.apps.soap.models import SOAPConnector
|
from passerelle.apps.soap.models import SOAPConnector
|
||||||
|
|
||||||
|
@ -289,6 +290,41 @@ class TestManage:
|
||||||
response = app.get(f'/soap/{connector.slug}/')
|
response = app.get(f'/soap/{connector.slug}/')
|
||||||
assert response.pyquery('.down')
|
assert response.pyquery('.down')
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('soap', [SOAP12], indirect=True)
|
||||||
|
def test_add(self, app, connector, soap):
|
||||||
|
response = app.get('/manage/soap/add')
|
||||||
|
form = response.form
|
||||||
|
form.set('slug', 'soap')
|
||||||
|
form.set('title', 'SOAP simple')
|
||||||
|
form.set('description', 'soap')
|
||||||
|
form.set('wsdl_url', soap.WSDL_URL)
|
||||||
|
# 302 means success
|
||||||
|
form.submit(status=302)
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('soap', [BrokenSOAP12], indirect=True)
|
||||||
|
def test_add_broken(self, app, connector, soap):
|
||||||
|
response = app.get('/manage/soap/add')
|
||||||
|
form = response.form
|
||||||
|
form.set('slug', 'soap')
|
||||||
|
form.set('title', 'SOAP simple')
|
||||||
|
form.set('description', 'soap')
|
||||||
|
form.set('wsdl_url', soap.WSDL_URL)
|
||||||
|
# 302 means success
|
||||||
|
form.submit(status=200)
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('soap', [SOAP12], indirect=True)
|
||||||
|
def test_add_with_tls_certificate(self, app, connector, soap):
|
||||||
|
response = app.get('/manage/soap/add')
|
||||||
|
form = response.form
|
||||||
|
form.set('slug', 'soap')
|
||||||
|
form.set('title', 'SOAP with TLS')
|
||||||
|
form.set('description', 'soap')
|
||||||
|
form.set('wsdl_url', soap.WSDL_URL)
|
||||||
|
with open('tests/data/cert.pem', 'rb') as fd:
|
||||||
|
form.set('client_certificate', Upload('cert.pem', fd.read(), 'application/octet-stream'))
|
||||||
|
# 302 means success
|
||||||
|
form.submit(status=302)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def connector(db, soap):
|
def connector(db, soap):
|
||||||
|
|
Loading…
Reference in New Issue