Files
wolfssl/wrapper/python/wolfssl/test/test_methods.py
T

60 lines
2.0 KiB
Python
Raw Normal View History

2016-11-22 11:56:39 -03:00
# -*- coding: utf-8 -*-
#
2016-09-22 12:27:20 -03:00
# test_methods.py
#
2020-01-03 15:06:03 -08:00
# Copyright (C) 2006-2020 wolfSSL Inc.
2016-09-22 12:27:20 -03:00
#
2019-03-15 10:37:36 -07:00
# This file is part of wolfSSL.
2016-09-22 12:27:20 -03:00
#
# 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
2019-03-15 10:37:36 -07:00
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
#/
2016-11-15 12:56:35 -03:00
# pylint: disable=missing-docstring, redefined-outer-name, import-error
2016-11-15 12:56:35 -03:00
import pytest
2016-11-15 12:56:35 -03:00
from wolfssl._methods import (WolfSSLMethod, PROTOCOL_SSLv3, PROTOCOL_SSLv23,
PROTOCOL_TLS, PROTOCOL_TLSv1, PROTOCOL_TLSv1_1,
PROTOCOL_TLSv1_2)
2016-09-22 12:27:20 -03:00
from wolfssl._ffi import ffi as _ffi
@pytest.fixture(
2017-01-15 12:51:09 -02:00
params=[-1, PROTOCOL_SSLv3, PROTOCOL_TLSv1, PROTOCOL_TLSv1_1],
ids=["invalid", "SSLv3", "TLSv1", "TLSv1_1"])
def unsupported_method(request):
yield request.param
2016-09-22 12:27:20 -03:00
@pytest.fixture(
params=[PROTOCOL_SSLv23, PROTOCOL_TLS, PROTOCOL_TLSv1_2],
ids=["SSLv23", "TLS", "TLSv1_2"])
def supported_method(request):
yield request.param
2016-09-22 12:27:20 -03:00
def test_unsupported_method(unsupported_method):
with pytest.raises(ValueError):
WolfSSLMethod(unsupported_method, False)
2016-09-22 12:27:20 -03:00
with pytest.raises(ValueError):
WolfSSLMethod(unsupported_method, True)
2016-09-22 12:27:20 -03:00
def test_supported_method(supported_method):
client = WolfSSLMethod(supported_method, False)
server = WolfSSLMethod(supported_method, True)
2016-09-22 12:27:20 -03:00
assert isinstance(client, WolfSSLMethod)
assert isinstance(server, WolfSSLMethod)
assert client.native_object != _ffi.NULL
assert server.native_object != _ffi.NULL