openssl.libssl: new destructors, to make sure the tests doesnt leak
parent
317a832a86
commit
cc6f03f5b5
|
@ -1,4 +1,5 @@
|
|||
USING: arrays kernel math openssl.libssl sequences tools.test ;
|
||||
USING: arrays destructors kernel math openssl openssl.libssl sequences
|
||||
tools.test ;
|
||||
USING: openssl ;
|
||||
|
||||
IN: openssl.libssl.tests
|
||||
|
@ -20,29 +21,50 @@ maybe-init-ssl
|
|||
: has-opt ( ctx op -- ? )
|
||||
swap SSL_CTRL_OPTIONS 0 f SSL_CTX_ctrl bitand 0 > ;
|
||||
|
||||
: new-ctx ( -- ctx )
|
||||
TLSv1_client_method SSL_CTX_new ;
|
||||
: new-ctx ( method -- ctx )
|
||||
SSL_CTX_new &SSL_CTX_free ;
|
||||
|
||||
: new-ssl ( -- ssl )
|
||||
new-ctx SSL_new ;
|
||||
: new-tls1-ctx ( -- ctx )
|
||||
TLSv1_client_method new-ctx ;
|
||||
|
||||
: new-ssl ( ctx -- ssl )
|
||||
SSL_new &SSL_free ;
|
||||
|
||||
{
|
||||
{ f f f }
|
||||
} [
|
||||
new-ctx tls-opts [ has-opt ] with map
|
||||
[
|
||||
new-tls1-ctx tls-opts [ has-opt ] with map
|
||||
] with-destructors
|
||||
] unit-test
|
||||
|
||||
! Test setting options
|
||||
{ 3 } [
|
||||
new-ctx tls-opts [ [ set-opt ] [ has-opt ] 2bi ] with map [ t = ] count
|
||||
[
|
||||
new-tls1-ctx tls-opts [ [ set-opt ] [ has-opt ] 2bi ] with map
|
||||
[ t = ] count
|
||||
] with-destructors
|
||||
] unit-test
|
||||
|
||||
! Initial state
|
||||
{ { "before/connect initialization" "read header" 1 f } } [
|
||||
new-ssl {
|
||||
[
|
||||
new-tls1-ctx new-ssl {
|
||||
SSL_state_string_long
|
||||
SSL_rstate_string_long
|
||||
SSL_want
|
||||
SSL_get_peer_certificate
|
||||
} [ execute( x -- x ) ] with map
|
||||
] with-destructors
|
||||
] unit-test
|
||||
|
||||
: method>version-string ( method -- str )
|
||||
new-ctx new-ssl SSL_get_version ;
|
||||
|
||||
! SSL_get_version
|
||||
{ { "TLSv1" "TLSv1.1" "TLSv1.2" } } [
|
||||
[
|
||||
TLSv1_method TLSv1_1_method TLSv1_2_method 3array
|
||||
[ method>version-string ] map
|
||||
] with-destructors
|
||||
] unit-test
|
||||
|
|
|
@ -422,8 +422,9 @@ FUNCTION: int SSL_get_error ( SSL* ssl, int ret )
|
|||
FUNCTION: void SSL_set_connect_state ( SSL* ssl )
|
||||
|
||||
FUNCTION: void SSL_set_accept_state ( SSL* ssl )
|
||||
|
||||
FUNCTION: void SSL_free ( SSL* ssl )
|
||||
DESTRUCTOR: SSL_free
|
||||
|
||||
FUNCTION: int SSL_accept ( SSL* ssl )
|
||||
FUNCTION: int SSL_connect ( SSL* ssl )
|
||||
FUNCTION: int SSL_read ( SSL* ssl, void* buf, int num )
|
||||
|
@ -448,6 +449,7 @@ FUNCTION: SSL* SSL_load_client_CA_file ( c-string file )
|
|||
! ------------------------------------------------------------------------------
|
||||
FUNCTION: SSL_CTX* SSL_CTX_new ( ssl-method method )
|
||||
FUNCTION: void SSL_CTX_free ( SSL_CTX* ctx )
|
||||
DESTRUCTOR: SSL_CTX_free
|
||||
|
||||
! Load the certificates and private keys into the SSL_CTX
|
||||
FUNCTION: int SSL_CTX_use_certificate_chain_file ( SSL_CTX* ctx,
|
||||
|
|
Loading…
Reference in New Issue