diff options
| author | Bastian Köcher <[email protected]> | 2018-03-11 11:29:45 +0100 |
|---|---|---|
| committer | Bastian Köcher <[email protected]> | 2018-03-11 11:34:36 +0100 |
| commit | d7a7c379a85965fa2a49849d9e424c2c11035d89 (patch) | |
| tree | 9228a3b494a30210dad0fdd12348a83e0fe07fa2 /openssl/src/x509/tests.rs | |
| parent | Moves store context init into its own function (diff) | |
| download | rust-openssl-d7a7c379a85965fa2a49849d9e424c2c11035d89.tar.xz rust-openssl-d7a7c379a85965fa2a49849d9e424c2c11035d89.zip | |
Changes `init` to take a closure which is called with the initialized context
After calling the closure, we automatically cleanup the context. This is
required, because otherwise we could have dangling references in the context.
Diffstat (limited to 'openssl/src/x509/tests.rs')
| -rw-r--r-- | openssl/src/x509/tests.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/openssl/src/x509/tests.rs b/openssl/src/x509/tests.rs index 9b630d0e..e3c726ae 100644 --- a/openssl/src/x509/tests.rs +++ b/openssl/src/x509/tests.rs @@ -306,11 +306,8 @@ fn test_verify_cert() { let store = store_bldr.build(); let mut context = X509StoreContext::new().unwrap(); - assert!(context.init(&store, &cert, &chain).is_ok()); - assert!(context.verify_cert().is_ok()); - context.cleanup(); - assert!(context.init(&store, &cert, &chain).is_ok()); - assert!(context.verify_cert().is_ok()); + assert!(context.init(&store, &cert, &chain, |c| c.verify_cert()).is_ok()); + assert!(context.init(&store, &cert, &chain, |c| c.verify_cert()).is_ok()); } #[test] @@ -326,6 +323,5 @@ fn test_verify_fails() { let store = store_bldr.build(); let mut context = X509StoreContext::new().unwrap(); - assert!(context.init(&store, &cert, &chain).is_ok()); - assert!(context.verify_cert().is_err()); + assert!(context.init(&store, &cert, &chain, |c| c.verify_cert()).is_err()); } |