summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-10-26 12:29:24 +1100
committerDamien George <damien.p.george@gmail.com>2017-10-26 12:29:24 +1100
commitf36975b6792f6b702dc9184adcdb6e0d89ce23b4 (patch)
tree64255a834249142b0183bf7b038fe4f39e0f3c67
parent328c1e78be68a386fe6fb5940027aad887c823a4 (diff)
tests/net_inet: Update tls test to work with CPython and incl new site.
CPython only supports the server_hostname keyword arg via the SSLContext object, so use that instead of the top-level ssl.wrap_socket. This allows the test to run on CPython the same as uPy. Also add the "Host:" header to correctly make a GET request (for URLs that are hosted on other servers). This is not strictly needed to test the SSL connection but helps to debug things when printing the response.
-rw-r--r--tests/net_inet/test_tls_sites.py5
-rw-r--r--tests/net_inet/test_tls_sites.py.exp1
2 files changed, 5 insertions, 1 deletions
diff --git a/tests/net_inet/test_tls_sites.py b/tests/net_inet/test_tls_sites.py
index 67345fd0b..bf8071d08 100644
--- a/tests/net_inet/test_tls_sites.py
+++ b/tests/net_inet/test_tls_sites.py
@@ -6,6 +6,8 @@ try:
import ussl as ssl
except:
import ssl
+ # CPython only supports server_hostname with SSLContext
+ ssl = ssl.SSLContext()
def test_one(site, opts):
@@ -22,7 +24,7 @@ def test_one(site, opts):
else:
s = ssl.wrap_socket(s)
- s.write(b"GET / HTTP/1.0\r\n\r\n")
+ s.write(b"GET / HTTP/1.0\r\nHost: %s\r\n\r\n" % bytes(site, 'latin'))
resp = s.read(4096)
# print(resp)
@@ -34,6 +36,7 @@ SITES = [
"google.com",
"www.google.com",
"api.telegram.org",
+ {"host": "api.pushbullet.com", "sni": True},
# "w9rybpfril.execute-api.ap-southeast-2.amazonaws.com",
{"host": "w9rybpfril.execute-api.ap-southeast-2.amazonaws.com", "sni": True},
]
diff --git a/tests/net_inet/test_tls_sites.py.exp b/tests/net_inet/test_tls_sites.py.exp
index 12732d1fa..2f3c113d2 100644
--- a/tests/net_inet/test_tls_sites.py.exp
+++ b/tests/net_inet/test_tls_sites.py.exp
@@ -1,4 +1,5 @@
google.com ok
www.google.com ok
api.telegram.org ok
+api.pushbullet.com ok
w9rybpfril.execute-api.ap-southeast-2.amazonaws.com ok