blob: c5efbd36a3401bc605692b7c91783168ee62d994 [file] [log] [blame]
Alex Gaynor5951f462014-11-16 09:08:42 -08001# This file is dual licensed under the terms of the Apache License, Version
2# 2.0, and the BSD License. See the LICENSE file in the root of this repository
3# for complete details.
Alex Gaynorc37feed2014-03-08 08:32:56 -08004
5from __future__ import absolute_import, division, print_function
6
Paul Kehrer7e4bc6d2013-12-24 22:23:53 -06007import pytest
8
Alex Gaynorb8b1d722016-03-19 16:47:30 -04009from cryptography.hazmat.backends.openssl import backend as openssl_backend
Alex Gaynor7aab8b42014-10-23 11:01:25 -070010
Alex Gaynor133a1792017-06-03 20:38:22 -040011from .utils import check_backend_support
Paul Kehrer34c075e2014-01-13 21:52:08 -050012
13
Alex Gaynorb8b1d722016-03-19 16:47:30 -040014def pytest_report_header(config):
Alex Gaynore85797b2016-03-19 16:51:05 -040015 return "OpenSSL: {0}".format(openssl_backend.openssl_version_text())
Alex Gaynorb8b1d722016-03-19 16:47:30 -040016
Alex Gaynor59303052016-03-19 16:48:18 -040017
Alex Gaynor133a1792017-06-03 20:38:22 -040018@pytest.fixture()
19def backend(request):
20 required_interfaces = [
21 mark.kwargs["interface"]
22 for mark in request.node.get_marker("requires_backend_interface")
23 ]
Alex Gaynore6055fb2017-06-03 22:02:50 -040024 if not all(
Alex Gaynor133a1792017-06-03 20:38:22 -040025 isinstance(openssl_backend, iface) for iface in required_interfaces
26 ):
Alex Gaynore6055fb2017-06-03 22:02:50 -040027 pytest.skip(
28 "OpenSSL doesn't implement required interfaces: {0}".format(
29 required_interfaces
30 )
Alex Gaynor133a1792017-06-03 20:38:22 -040031 )
Paul Kehrer7e4bc6d2013-12-24 22:23:53 -060032
Alex Gaynore6055fb2017-06-03 22:02:50 -040033 check_backend_support(openssl_backend, request)
34 return openssl_backend