From d6d2527692195f074c4a384a11bbb7c6aa187826 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 16 Mar 2017 16:39:35 -0400 Subject: Write a memory leak test for X.509 extensions (#3451) * Bind a pair of mem functions. * do the conditional correctly * move to the right section * Get the code basically working * flake8 * say the correct incantation * WOrkaround for hilarity * Revert "WOrkaround for hilarity" This reverts commit 37b9f3b4ed4063eef5add3bb5d5dd592a007d439. * Swap out these functions for the originals * nonsense for windows * try writing this all out for windows * Debugging utility * Avoid this mess, don't dlopen anything * Throw away this FFI entirely * first pass at some x.509 memleak tests * TODO and fix * Get the tests to passing * String formatting is nasty * some fixes because rebasing * fix for the name API, always use the OpenSSL backend --- tests/hazmat/backends/test_openssl_memleak.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/hazmat') diff --git a/tests/hazmat/backends/test_openssl_memleak.py b/tests/hazmat/backends/test_openssl_memleak.py index 8df54774..e4cbd0fb 100644 --- a/tests/hazmat/backends/test_openssl_memleak.py +++ b/tests/hazmat/backends/test_openssl_memleak.py @@ -163,3 +163,25 @@ class TestAssertNoMemoryLeaks(object): def func(): raise ZeroDivisionError """)) + + +@skip_if_memtesting_not_supported() +class TestOpenSSLMemoryLeaks(object): + @pytest.mark.parametrize("path", [ + "x509/PKITS_data/certs/ValidcRLIssuerTest28EE.crt", + ]) + def test_x509_extensions(self, path): + assert_no_memory_leaks(textwrap.dedent(""" + def func(path): + from cryptography import x509 + from cryptography.hazmat.backends.openssl import backend + + import cryptography_vectors + + with cryptography_vectors.open_vector_file(path, "rb") as f: + cert = x509.load_der_x509_certificate( + f.read(), backend + ) + + cert.extensions + """), [path]) -- cgit v1.2.3