mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
Python: clean up tests
This commit is contained in:
@@ -56,58 +56,11 @@ def test_fluent_ssl():
|
||||
print(ssock.version())
|
||||
|
||||
|
||||
def test_fluent_ssl_no_TLSv1():
|
||||
hostname = 'www.python.org'
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
context.options |= ssl.OP_NO_TLSv1
|
||||
|
||||
with socket.create_connection((hostname, 443)) as sock:
|
||||
with context.wrap_socket(sock, server_hostname=hostname) as ssock:
|
||||
print(ssock.version())
|
||||
|
||||
def test_fluent_ssl_safe():
|
||||
hostname = 'www.python.org'
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
context.options |= ssl.OP_NO_TLSv1
|
||||
context.options |= ssl.OP_NO_TLSv1_1
|
||||
|
||||
with socket.create_connection((hostname, 443)) as sock:
|
||||
with context.wrap_socket(sock, server_hostname=hostname) as ssock:
|
||||
print(ssock.version())
|
||||
|
||||
def test_fluent_ssl_safe_combined():
|
||||
hostname = 'www.python.org'
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
|
||||
|
||||
with socket.create_connection((hostname, 443)) as sock:
|
||||
with context.wrap_socket(sock, server_hostname=hostname) as ssock:
|
||||
print(ssock.version())
|
||||
|
||||
def test_fluent_ssl_unsafe_combined_wrongly():
|
||||
hostname = 'www.python.org'
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
context.options |= ssl.OP_NO_TLSv1 & ssl.OP_NO_TLSv1_1
|
||||
|
||||
with socket.create_connection((hostname, 443)) as sock:
|
||||
with context.wrap_socket(sock, server_hostname=hostname) as ssock:
|
||||
print(ssock.version())
|
||||
|
||||
def test_fluent_ssl_safe_combined_multiple():
|
||||
hostname = 'www.python.org'
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1 | ssl.OP_NO_TLSv1_2
|
||||
|
||||
with socket.create_connection((hostname, 443)) as sock:
|
||||
with context.wrap_socket(sock, server_hostname=hostname) as ssock:
|
||||
print(ssock.version())
|
||||
|
||||
|
||||
def create_relaxed_context():
|
||||
return ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
return ssl.SSLContext(ssl.PROTOCOL_TLS)
|
||||
|
||||
def create_secure_context():
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
|
||||
context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
|
||||
return context
|
||||
|
||||
@@ -143,21 +96,21 @@ def test_delegated_context_made_unsafe():
|
||||
print(ssock.version())
|
||||
|
||||
def test_delegated_connection_unsafe():
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
|
||||
create_connection(context)
|
||||
|
||||
def test_delegated_connection_safe():
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
|
||||
context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
|
||||
create_connection(context)
|
||||
|
||||
def test_delegated_connection_made_safe():
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
|
||||
context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
|
||||
create_connection(context)
|
||||
|
||||
def test_delegated_connection_made_unsafe():
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
|
||||
context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
|
||||
context.options &= ~ssl.OP_NO_TLSv1_1
|
||||
create_connection(context)
|
||||
|
||||
Reference in New Issue
Block a user