Test methods test_get_cipher_* have been split into two sets.
assertTrue(isinstance was replaced with assertIsInstance.
assertEqual for None was replaced with assertIs.
Added entries to doc/api/ssl.rst.
diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py
index 983dc96..4c2dff5 100644
--- a/OpenSSL/test/test_ssl.py
+++ b/OpenSSL/test/test_ssl.py
@@ -1932,60 +1932,72 @@
# XXX want_read
+ def test_get_cipher_name_before_connect(self):
+ """
+ :py:obj:`Connection.get_cipher_name` returns :py:obj:`None`
+ if no connection has been established.
+ """
+ ctx = Context(TLSv1_METHOD)
+ conn = Connection(ctx, None)
+ self.assertIs(conn.get_cipher_name(), None)
+
def test_get_cipher_name(self):
"""
:py:obj:`Connection.get_cipher_name` returns the name of the currently
- used cipher or :py:obj:`None` if no connection has been established.
+ used cipher.
"""
- # if connection is not established Connection.cipher returns None.
- ctx = Context(TLSv1_METHOD)
- conn = Connection(ctx, None)
- self.assertEqual(conn.get_cipher_name(), None)
-
server, client = self._loopback()
server_cipher_name, client_cipher_name = \
server.get_cipher_name(), client.get_cipher_name()
- self.assertTrue(isinstance(server_cipher_name, str))
- self.assertTrue(isinstance(client_cipher_name, str))
+ self.assertIsInstance(server_cipher_name, str)
+ self.assertIsInstance(client_cipher_name, str)
self.assertEqual(server_cipher_name, client_cipher_name)
+ def test_get_cipher_version_before_connect(self):
+ """
+ :py:obj:`Connection.get_cipher_version` returns :py:obj:`None`
+ if no connection has been established.
+ """
+ ctx = Context(TLSv1_METHOD)
+ conn = Connection(ctx, None)
+ self.assertIs(conn.get_cipher_version(), None)
+
def test_get_cipher_version(self):
"""
:py:obj:`Connection.get_cipher_version` returns the protocol name of the currently
- used cipher or :py:obj:`None` if no connection has been established.
+ used cipher.
"""
- # if connection is not established Connection.cipher returns None.
- ctx = Context(TLSv1_METHOD)
- conn = Connection(ctx, None)
- self.assertEqual(conn.get_cipher_version(), None)
-
server, client = self._loopback()
server_cipher_version, client_cipher_version = \
server.get_cipher_version(), client.get_cipher_version()
- self.assertTrue(isinstance(server_cipher_version, str))
- self.assertTrue(isinstance(client_cipher_version, str))
+ self.assertIsInstance(server_cipher_version, str)
+ self.assertIsInstance(client_cipher_version, str)
self.assertEqual(server_cipher_version, client_cipher_version)
+ def test_get_cipher_bits_before_connect(self):
+ """
+ :py:obj:`Connection.get_cipher_bits` returns :py:obj:`None`
+ if no connection has been established.
+ """
+ ctx = Context(TLSv1_METHOD)
+ conn = Connection(ctx, None)
+ self.assertIs(conn.get_cipher_bits(), None)
+
def test_get_cipher_bits(self):
"""
:py:obj:`Connection.get_cipher_bits` returns the number of secret bits of the currently
- used cipher or :py:obj:`None` if no connection has been established.
+ used cipher.
"""
- # if connection is not established Connection.cipher returns None.
- ctx = Context(TLSv1_METHOD)
- conn = Connection(ctx, None)
- self.assertEqual(conn.get_cipher_bits(), None)
-
server, client = self._loopback()
server_cipher_bits, client_cipher_bits = \
server.get_cipher_bits(), client.get_cipher_bits()
- self.assertTrue(isinstance(server_cipher_bits, int))
- self.assertTrue(isinstance(client_cipher_bits, int))
+ self.assertIsInstance(server_cipher_bits, int)
+ self.assertIsInstance(client_cipher_bits, int)
self.assertEqual(server_cipher_bits, client_cipher_bits)
diff --git a/doc/api/ssl.rst b/doc/api/ssl.rst
index b506757..570fa7d 100644
--- a/doc/api/ssl.rst
+++ b/doc/api/ssl.rst
@@ -765,6 +765,23 @@
.. versionadded:: 0.14
+.. py:method:: Connection.get_cipher_name()
+
+ Obtain the name of the currently used cipher.
+
+ .. versionadded:: 0.15
+
+.. py:method:: Connection.get_cipher_bits()
+
+ Obtain the number of secret bits of the currently used cipher.
+
+ .. versionadded:: 0.15
+
+.. py:method:: Connection.get_cipher_version()
+
+ Obtain the protocol name of the currently used cipher.
+
+ .. versionadded:: 0.15
.. Rubric:: Footnotes
diff --git a/setup.py b/setup.py
index 058ad7b..3e7605d 100755
--- a/setup.py
+++ b/setup.py
@@ -34,7 +34,7 @@
maintainer_email = 'exarkun@twistedmatrix.com',
url = 'https://github.com/pyca/pyopenssl',
license = 'APL2',
- install_requires=["cryptography>=0.2.1", "six>=1.5.2"],
+ install_requires=["cryptography>=0.2.2", "six>=1.5.2"],
long_description = """\
High-level wrapper around a subset of the OpenSSL library, includes
* SSL.Connection objects, wrapping the methods of Python's portable