Skip to content

Commit 094d2f3

Browse files
committed
Python: clean up tests
1 parent a44490b commit 094d2f3

File tree

1 file changed

+6
-53
lines changed

1 file changed

+6
-53
lines changed

python/ql/test/query-tests/Security/CWE-327/ssl_fluent.py

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -56,58 +56,11 @@ def test_fluent_ssl():
5656
print(ssock.version())
5757

5858

59-
def test_fluent_ssl_no_TLSv1():
60-
hostname = 'www.python.org'
61-
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
62-
context.options |= ssl.OP_NO_TLSv1
63-
64-
with socket.create_connection((hostname, 443)) as sock:
65-
with context.wrap_socket(sock, server_hostname=hostname) as ssock:
66-
print(ssock.version())
67-
68-
def test_fluent_ssl_safe():
69-
hostname = 'www.python.org'
70-
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
71-
context.options |= ssl.OP_NO_TLSv1
72-
context.options |= ssl.OP_NO_TLSv1_1
73-
74-
with socket.create_connection((hostname, 443)) as sock:
75-
with context.wrap_socket(sock, server_hostname=hostname) as ssock:
76-
print(ssock.version())
77-
78-
def test_fluent_ssl_safe_combined():
79-
hostname = 'www.python.org'
80-
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
81-
context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
82-
83-
with socket.create_connection((hostname, 443)) as sock:
84-
with context.wrap_socket(sock, server_hostname=hostname) as ssock:
85-
print(ssock.version())
86-
87-
def test_fluent_ssl_unsafe_combined_wrongly():
88-
hostname = 'www.python.org'
89-
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
90-
context.options |= ssl.OP_NO_TLSv1 & ssl.OP_NO_TLSv1_1
91-
92-
with socket.create_connection((hostname, 443)) as sock:
93-
with context.wrap_socket(sock, server_hostname=hostname) as ssock:
94-
print(ssock.version())
95-
96-
def test_fluent_ssl_safe_combined_multiple():
97-
hostname = 'www.python.org'
98-
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
99-
context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1 | ssl.OP_NO_TLSv1_2
100-
101-
with socket.create_connection((hostname, 443)) as sock:
102-
with context.wrap_socket(sock, server_hostname=hostname) as ssock:
103-
print(ssock.version())
104-
105-
10659
def create_relaxed_context():
107-
return ssl.SSLContext(ssl.PROTOCOL_SSLv23)
60+
return ssl.SSLContext(ssl.PROTOCOL_TLS)
10861

10962
def create_secure_context():
110-
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
63+
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
11164
context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
11265
return context
11366

@@ -143,21 +96,21 @@ def test_delegated_context_made_unsafe():
14396
print(ssock.version())
14497

14598
def test_delegated_connection_unsafe():
146-
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
99+
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
147100
create_connection(context)
148101

149102
def test_delegated_connection_safe():
150-
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
103+
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
151104
context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
152105
create_connection(context)
153106

154107
def test_delegated_connection_made_safe():
155-
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
108+
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
156109
context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
157110
create_connection(context)
158111

159112
def test_delegated_connection_made_unsafe():
160-
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
113+
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
161114
context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
162115
context.options &= ~ssl.OP_NO_TLSv1_1
163116
create_connection(context)

0 commit comments

Comments
 (0)