mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-01-28 00:42:20 +01:00
adds methods and client tests;
adds context creation; adds memory module; removes init and cleanup functions.
This commit is contained in:
45
wrapper/python/wolfssl/test/test_client.py
Normal file
45
wrapper/python/wolfssl/test/test_client.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# test_client.py
|
||||
#
|
||||
# Copyright (C) 2006-2016 wolfSSL Inc.
|
||||
#
|
||||
# This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||
#
|
||||
# wolfSSL is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# wolfSSL is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
import unittest
|
||||
import socket
|
||||
import wolfssl
|
||||
import ssl
|
||||
|
||||
class SSLClientTest(unittest.TestCase):
|
||||
ssl_provider = ssl
|
||||
host = "www.google.com"
|
||||
port = 443
|
||||
|
||||
def setUp(self):
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
def test_wrap_socket(self):
|
||||
self.secure_sock = self.ssl_provider.wrap_socket(
|
||||
self.sock, ssl_version=ssl.PROTOCOL_TLSv1_2)
|
||||
self.secure_sock.connect((self.host, self.port))
|
||||
|
||||
self.secure_sock.send(b"GET / HTTP/1.1\n\n")
|
||||
self.assertEquals(b"HTTP", self.secure_sock.recv(4))
|
||||
|
||||
self.secure_sock.close()
|
||||
|
||||
|
||||
#class TestWolfSSL(SSLClientTest):
|
||||
# ssl_provider = wolfssl
|
||||
71
wrapper/python/wolfssl/test/test_methods.py
Normal file
71
wrapper/python/wolfssl/test/test_methods.py
Normal file
@@ -0,0 +1,71 @@
|
||||
# test_methods.py
|
||||
#
|
||||
# Copyright (C) 2006-2016 wolfSSL Inc.
|
||||
#
|
||||
# This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||
#
|
||||
# wolfSSL is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# wolfSSL is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
import unittest
|
||||
from wolfssl._methods import *
|
||||
from wolfssl._ffi import ffi as _ffi
|
||||
|
||||
|
||||
class TestMethods(unittest.TestCase):
|
||||
def test_SSLv3_raises(self):
|
||||
self.assertRaises(ValueError, WolfSSLMethod, PROTOCOL_SSLv3, False)
|
||||
self.assertRaises(ValueError, WolfSSLMethod, PROTOCOL_SSLv3, True)
|
||||
|
||||
|
||||
def test_TLSv1_raises(self):
|
||||
self.assertRaises(ValueError, WolfSSLMethod, PROTOCOL_TLSv1, False)
|
||||
self.assertRaises(ValueError, WolfSSLMethod, PROTOCOL_TLSv1, True)
|
||||
|
||||
|
||||
def test_TLSv1_1_raises(self):
|
||||
self.assertRaises(ValueError, WolfSSLMethod, PROTOCOL_TLSv1_1, False)
|
||||
self.assertRaises(ValueError, WolfSSLMethod, PROTOCOL_TLSv1_1, True)
|
||||
|
||||
|
||||
def test_SSLv23_doesnt_raises(self):
|
||||
client = WolfSSLMethod(PROTOCOL_SSLv23, False)
|
||||
server = WolfSSLMethod(PROTOCOL_SSLv23, True)
|
||||
|
||||
self.assertIsInstance(client, WolfSSLMethod)
|
||||
self.assertIsInstance(server, WolfSSLMethod)
|
||||
|
||||
self.assertNotEquals(client.native_object, _ffi.NULL)
|
||||
self.assertNotEquals(server.native_object, _ffi.NULL)
|
||||
|
||||
|
||||
def test_TLS_doesnt_raises(self):
|
||||
client = WolfSSLMethod(PROTOCOL_TLS, False)
|
||||
server = WolfSSLMethod(PROTOCOL_TLS, True)
|
||||
|
||||
self.assertIsInstance(client, WolfSSLMethod)
|
||||
self.assertIsInstance(server, WolfSSLMethod)
|
||||
|
||||
self.assertNotEquals(client.native_object, _ffi.NULL)
|
||||
self.assertNotEquals(server.native_object, _ffi.NULL)
|
||||
|
||||
|
||||
def test_TLSv1_2_doesnt_raises(self):
|
||||
client = WolfSSLMethod(PROTOCOL_TLSv1_2, False)
|
||||
server = WolfSSLMethod(PROTOCOL_TLSv1_2, True)
|
||||
|
||||
self.assertIsInstance(client, WolfSSLMethod)
|
||||
self.assertIsInstance(server, WolfSSLMethod)
|
||||
|
||||
self.assertNotEquals(client.native_object, _ffi.NULL)
|
||||
self.assertNotEquals(server.native_object, _ffi.NULL)
|
||||
Reference in New Issue
Block a user