Merge pull request #49632 from evillique/fix-ssl-test

Try to fix integration test 'test_ssl_cert_authentication'
This commit is contained in:
Nikolay Degterinsky 2023-05-09 11:53:21 +02:00 committed by GitHub
commit 39deaf4f2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -164,19 +164,24 @@ def get_ssl_context(cert_name):
def execute_query_https(
query, user, enable_ssl_auth=True, cert_name=None, password=None
):
url = (
f"https://{instance.ip_address}:{HTTPS_PORT}/?query={urllib.parse.quote(query)}"
)
request = urllib.request.Request(url)
request.add_header("X-ClickHouse-User", user)
if enable_ssl_auth:
request.add_header("X-ClickHouse-SSL-Certificate-Auth", "on")
if password:
request.add_header("X-ClickHouse-Key", password)
response = urllib.request.urlopen(
request, context=get_ssl_context(cert_name)
).read()
return response.decode("utf-8")
retries = 10
while True:
try:
url = f"https://{instance.ip_address}:{HTTPS_PORT}/?query={urllib.parse.quote(query)}"
request = urllib.request.Request(url)
request.add_header("X-ClickHouse-User", user)
if enable_ssl_auth:
request.add_header("X-ClickHouse-SSL-Certificate-Auth", "on")
if password:
request.add_header("X-ClickHouse-Key", password)
response = urllib.request.urlopen(
request, context=get_ssl_context(cert_name)
).read()
return response.decode("utf-8")
except BrokenPipeError:
retries -= 1
if retries == 0:
raise
def test_https():