summaryrefslogtreecommitdiff
path: root/tests/extmod/ussl_basic.py
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-08-18 16:57:45 +1000
committerJim Mussared <jim.mussared@gmail.com>2023-06-08 17:54:24 +1000
commit4216bc7d1351feb8199e4ebbff1a9598aa1c5b02 (patch)
tree5085738ef65ab377c221f290c7fa90ec2acd4d29 /tests/extmod/ussl_basic.py
parent5e50975a6dd9466afafbcd012c00078093fe1f57 (diff)
tests: Replace umodule with module everywhere.
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'tests/extmod/ussl_basic.py')
-rw-r--r--tests/extmod/ussl_basic.py69
1 files changed, 0 insertions, 69 deletions
diff --git a/tests/extmod/ussl_basic.py b/tests/extmod/ussl_basic.py
deleted file mode 100644
index dd3b6f0b9..000000000
--- a/tests/extmod/ussl_basic.py
+++ /dev/null
@@ -1,69 +0,0 @@
-# very basic test of ssl module, just to test the methods exist
-
-try:
- import uio as io
- import ussl as ssl
-except ImportError:
- print("SKIP")
- raise SystemExit
-
-
-class TestSocket(io.IOBase):
- def write(self, buf):
- return len(buf)
-
- def readinto(self, buf):
- return 0
-
- def ioctl(self, cmd, arg):
- print("TestSocket.ioctl", cmd, arg)
- return 0
-
- def setblocking(self, value):
- print("TestSocket.setblocking({})".format(value))
-
-
-# create in client mode
-try:
- ss = ssl.wrap_socket(TestSocket(), server_hostname="test.example.com")
-except OSError as er:
- print("OSError: client")
-
-# create in server mode (can use this object for further tests)
-ss = ssl.wrap_socket(TestSocket(), server_side=1, do_handshake=0)
-
-# print
-print(repr(ss)[:12])
-
-# setblocking() propagates call to the underlying stream object
-ss.setblocking(False)
-ss.setblocking(True)
-
-# write
-try:
- ss.write(b"aaaa")
-except OSError:
- pass
-
-# read (underlying socket has no data)
-try:
- ss.read(8)
-except OSError:
- pass
-
-# close
-ss.close()
-# close 2nd time
-ss.close()
-
-# read on closed socket
-try:
- ss.read(10)
-except OSError as er:
- print("OSError: read")
-
-# write on closed socket
-try:
- ss.write(b"aaaa")
-except OSError as er:
- print("OSError: write")