]> WPIA git - cassiopeia.git/blobdiff - test/src/slipBioTest.cpp
add: Full CRL tranfer (non-chunked)
[cassiopeia.git] / test / src / slipBioTest.cpp
index 7b45158ba010dbc88d5f7c259d1ddc78161b1815..d579eb383cba9caecae8810b8a9bd01c2ef1941d 100644 (file)
@@ -6,9 +6,9 @@
 #include <openssl/ssl.h>
 #include <openssl/err.h>
 
-#include "bios.h"
-#include "opensslBIO.h"
-#include "slipBio.h"
+#include "io/bios.h"
+#include "io/opensslBIO.h"
+#include "io/slipBio.h"
 
 class OpensslBIOVector : public OpensslBIO {
 private:
@@ -107,15 +107,16 @@ BOOST_AUTO_TEST_CASE( TestSLIP ) {
     BOOST_CHECK_EQUAL( res, 2 );
     char res3[] = {( char ) 0xdb, 2};
     BOOST_CHECK_EQUAL_COLLECTIONS( buf, buf + 2, res3, res3 + 2 );
+    delete slip;
 }
 
 BOOST_AUTO_TEST_CASE( TestSSLThroughSLIP ) {
     BIO* bio1, *bio2;
     BOOST_REQUIRE_EQUAL( BIO_new_bio_pair( &bio1, 8096, &bio2, 8096 ), 1 );
     BIO* slip1 = BIO_new( toBio<SlipBIO>() );
-    ( ( SlipBIO* )slip1->ptr )->setTarget( std::shared_ptr<OpensslBIO>( new OpensslBIOWrapper( bio1 ) ) );
+    ( ( SlipBIO* )slip1->ptr )->setTarget( std::shared_ptr<OpensslBIO>( new OpensslBIOWrapper( std::shared_ptr<BIO>( bio1, BIO_free ) ) ) );
     BIO* slip2 = BIO_new( toBio<SlipBIO>() );
-    ( ( SlipBIO* )slip2->ptr )->setTarget( std::shared_ptr<OpensslBIO>( new OpensslBIOWrapper( bio2 ) ) );
+    ( ( SlipBIO* )slip2->ptr )->setTarget( std::shared_ptr<OpensslBIO>( new OpensslBIOWrapper( std::shared_ptr<BIO>( bio2, BIO_free ) ) ) );
 
     auto meth = TLSv1_method();
     auto c_ctx = SSL_CTX_new( meth );
@@ -138,8 +139,8 @@ BOOST_AUTO_TEST_CASE( TestSSLThroughSLIP ) {
 
     char data[] = {1, 2, 3, 4, 5};
     char data2[5];
-    ERR_load_SSL_strings();
-    ERR_load_crypto_strings();
+    //ERR_load_SSL_strings();
+    //ERR_load_crypto_strings();
 
     int res = BIO_write( c_bio, data, 5 );
     BOOST_CHECK_EQUAL( res, -1 );
@@ -149,7 +150,6 @@ BOOST_AUTO_TEST_CASE( TestSSLThroughSLIP ) {
     res = BIO_write( c_bio, data, 5 );
     BOOST_CHECK_EQUAL( res, -1 );
 
-
     res = BIO_read( s_bio, data2, sizeof( data2 ) );
     BOOST_CHECK_EQUAL( res, -1 );
     res = BIO_write( c_bio, data, 5 );
@@ -157,6 +157,17 @@ BOOST_AUTO_TEST_CASE( TestSSLThroughSLIP ) {
     res = BIO_read( s_bio, data2, sizeof( data2 ) );
     BOOST_CHECK_EQUAL( res, 5 );
     BOOST_CHECK_EQUAL_COLLECTIONS( data, data + 5, data2, data2 + 5 );
+
+    BIO_free( c_bio );
+    BIO_free( s_bio );
+
+    BIO_free( slip1 );
+    BIO_free( slip2 );
+    SSL_free( c_ssl );
+    SSL_free( s_ssl );
+
+    SSL_CTX_free( c_ctx );
+    SSL_CTX_free( s_ctx );
 }
 
 BOOST_AUTO_TEST_SUITE_END()