From 38717628f833a2568b379f9ed563220ec5c57ee5 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sun, 20 Apr 2014 14:57:29 -0500 Subject: fix SSL_OP_ALL being unusable on Windows due to long being 32-bit signed --- tests/hazmat/bindings/test_openssl.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests') diff --git a/tests/hazmat/bindings/test_openssl.py b/tests/hazmat/bindings/test_openssl.py index acab22b1..cf3024a7 100644 --- a/tests/hazmat/bindings/test_openssl.py +++ b/tests/hazmat/bindings/test_openssl.py @@ -103,3 +103,37 @@ class TestOpenSSL(object): b = Binding() res = b.lib.Cryptography_add_osrandom_engine() assert res == 2 + + # Test that we're properly handling 32-bit unsigned on all platforms + def test_ssl_ctx_options(self): + b = Binding() + assert b.lib.SSL_OP_ALL > 0 + ctx = b.lib.SSL_CTX_new(b.lib.TLSv1_method()) + ctx = b.ffi.gc(ctx, b.lib.SSL_CTX_free) + resp = b.lib.SSL_CTX_set_options(ctx, b.lib.SSL_OP_ALL) + assert resp == b.lib.SSL_OP_ALL + assert b.lib.SSL_OP_ALL == b.lib.SSL_CTX_get_options(ctx) + + # Test that we're properly handling 32-bit unsigned on all platforms + def test_ssl_options(self): + b = Binding() + assert b.lib.SSL_OP_ALL > 0 + ctx = b.lib.SSL_CTX_new(b.lib.TLSv1_method()) + ctx = b.ffi.gc(ctx, b.lib.SSL_CTX_free) + ssl = b.lib.SSL_new(ctx) + ssl = b.ffi.gc(ssl, b.lib.SSL_free) + resp = b.lib.SSL_set_options(ssl, b.lib.SSL_OP_ALL) + assert resp == b.lib.SSL_OP_ALL + assert b.lib.SSL_OP_ALL == b.lib.SSL_get_options(ssl) + + # Test that we're properly handling 32-bit unsigned on all platforms + def test_ssl_mode(self): + b = Binding() + assert b.lib.SSL_OP_ALL > 0 + ctx = b.lib.SSL_CTX_new(b.lib.TLSv1_method()) + ctx = b.ffi.gc(ctx, b.lib.SSL_CTX_free) + ssl = b.lib.SSL_new(ctx) + ssl = b.ffi.gc(ssl, b.lib.SSL_free) + resp = b.lib.SSL_set_mode(ssl, b.lib.SSL_OP_ALL) + assert resp == b.lib.SSL_OP_ALL + assert b.lib.SSL_OP_ALL == b.lib.SSL_get_mode(ssl) -- cgit v1.2.3 From 704f2f382f3a6385ce5f0f728168590b7ac53a3d Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sun, 20 Apr 2014 15:26:53 -0500 Subject: move some comments --- tests/hazmat/bindings/test_openssl.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/hazmat/bindings/test_openssl.py b/tests/hazmat/bindings/test_openssl.py index cf3024a7..1dbd23b4 100644 --- a/tests/hazmat/bindings/test_openssl.py +++ b/tests/hazmat/bindings/test_openssl.py @@ -104,8 +104,8 @@ class TestOpenSSL(object): res = b.lib.Cryptography_add_osrandom_engine() assert res == 2 - # Test that we're properly handling 32-bit unsigned on all platforms def test_ssl_ctx_options(self): + # Test that we're properly handling 32-bit unsigned on all platforms. b = Binding() assert b.lib.SSL_OP_ALL > 0 ctx = b.lib.SSL_CTX_new(b.lib.TLSv1_method()) @@ -114,8 +114,8 @@ class TestOpenSSL(object): assert resp == b.lib.SSL_OP_ALL assert b.lib.SSL_OP_ALL == b.lib.SSL_CTX_get_options(ctx) - # Test that we're properly handling 32-bit unsigned on all platforms def test_ssl_options(self): + # Test that we're properly handling 32-bit unsigned on all platforms. b = Binding() assert b.lib.SSL_OP_ALL > 0 ctx = b.lib.SSL_CTX_new(b.lib.TLSv1_method()) @@ -126,8 +126,8 @@ class TestOpenSSL(object): assert resp == b.lib.SSL_OP_ALL assert b.lib.SSL_OP_ALL == b.lib.SSL_get_options(ssl) - # Test that we're properly handling 32-bit unsigned on all platforms def test_ssl_mode(self): + # Test that we're properly handling 32-bit unsigned on all platforms. b = Binding() assert b.lib.SSL_OP_ALL > 0 ctx = b.lib.SSL_CTX_new(b.lib.TLSv1_method()) -- cgit v1.2.3