Jean-Paul Calderone | a566e4e | 2014-03-25 21:01:10 -0400 | [diff] [blame^] | 1 | # Copyright (C) Jean-Paul Calderone |
| 2 | # See LICENSE for details. |
Jean-Paul Calderone | 65627a2 | 2014-03-25 20:58:30 -0400 | [diff] [blame] | 3 | |
| 4 | """ |
| 5 | Unit tests for :py:obj:`OpenSSL.tsafe`. |
| 6 | """ |
| 7 | |
Jean-Paul Calderone | a566e4e | 2014-03-25 21:01:10 -0400 | [diff] [blame^] | 8 | from OpenSSL.SSL import TLSv1_METHOD, Context |
| 9 | from OpenSSL.tsafe import Connection |
| 10 | from OpenSSL.test.util import TestCase |
Jean-Paul Calderone | 65627a2 | 2014-03-25 20:58:30 -0400 | [diff] [blame] | 11 | from OpenSSL.test.test_ssl import _create_certificate_chain |
| 12 | |
| 13 | |
| 14 | class ConnectionTest(TestCase): |
| 15 | """ |
Jean-Paul Calderone | a566e4e | 2014-03-25 21:01:10 -0400 | [diff] [blame^] | 16 | Tests for :py:obj:`OpenSSL.tsafe.Connection`. |
Jean-Paul Calderone | 65627a2 | 2014-03-25 20:58:30 -0400 | [diff] [blame] | 17 | """ |
Jean-Paul Calderone | a566e4e | 2014-03-25 21:01:10 -0400 | [diff] [blame^] | 18 | def test_instantiation(self): |
Jean-Paul Calderone | 65627a2 | 2014-03-25 20:58:30 -0400 | [diff] [blame] | 19 | """ |
Jean-Paul Calderone | a566e4e | 2014-03-25 21:01:10 -0400 | [diff] [blame^] | 20 | :py:obj:`OpenSSL.tsafe.Connection` can be instantiated. |
Jean-Paul Calderone | 65627a2 | 2014-03-25 20:58:30 -0400 | [diff] [blame] | 21 | """ |
| 22 | chain = _create_certificate_chain() |
| 23 | [(_, _), (ikey, icert), (skey, scert)] = chain |
| 24 | |
| 25 | # Create the server context |
| 26 | ctx = Context(TLSv1_METHOD) |
| 27 | ctx.use_privatekey(skey) |
| 28 | ctx.use_certificate(scert) |
| 29 | |
Jean-Paul Calderone | a566e4e | 2014-03-25 21:01:10 -0400 | [diff] [blame^] | 30 | # The following line should not throw an error. This isn't an ideal |
| 31 | # test. It would be great to refactor the other Connection tests so |
| 32 | # they could automatically be applied to this class too. |
| 33 | Connection(ctx, None) |