summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2015-08-28 03:07:24 +0200
committerRichard Levitte <levitte@openssl.org>2015-09-07 16:10:58 +0200
commitc27a4049475428b902004a47104c17e1eaaadd20 (patch)
treea162dca7f5861f56f452f28ebbcaa2324404fd6c /test
parent25be5f44b81e1c45e15e689ba55713e455dfe624 (diff)
Remake test/sslsessionticktest.pl into a recipe
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'test')
-rwxr-xr-xtest/recipes/70-test_sslsessiontick.t (renamed from test/sslsessionticktest.pl)91
1 files changed, 52 insertions, 39 deletions
diff --git a/test/sslsessionticktest.pl b/test/recipes/70-test_sslsessiontick.t
index 922a3595f4..7f90beae63 100755
--- a/test/sslsessionticktest.pl
+++ b/test/recipes/70-test_sslsessiontick.t
@@ -53,9 +53,24 @@
# Hudson (tjh@cryptsoft.com).
use strict;
+use OpenSSL::Test qw/:DEFAULT cmdstr top_file top_dir/;
use TLSProxy::Proxy;
use File::Temp qw(tempfile);
+my $test_name = "test_sslsessiontick";
+setup($test_name);
+
+plan skip_all => "$test_name can only be performed with OpenSSL configured shared"
+ unless (map { chomp; s/^SHARED_LIBS=\s*//; $_ }
+ grep { /^SHARED_LIBS=/ }
+ do { local @ARGV = ( top_file("Makefile") ); <> })[0] ne "";
+
+$ENV{OPENSSL_ENGINES} = top_dir("engines");
+$ENV{OPENSSL_ia32cap} = '~0x200000200000000';
+
+sub checkmessages($$$$$$);
+sub clearall();
+
my $chellotickext = 0;
my $shellotickext = 0;
my $fullhand = 0;
@@ -63,9 +78,12 @@ my $ticketseen = 0;
my $proxy = TLSProxy::Proxy->new(
undef,
- @ARGV
+ cmdstr(app(["openssl"])),
+ top_file("apps", "server.pem")
);
+plan tests => 5;
+
#Test 1: By default with no existing session we should get a session ticket
#Expected result: ClientHello extension seen; ServerHello extension seen
# NewSessionTicket message seen; Full handshake
@@ -107,7 +125,7 @@ checkmessages(4, "Session resumption session ticket test", 1, 0, 0, 0);
#Expected result: ClientHello extension seen; ServerHello extension seen
# NewSessionTicket message seen; Abbreviated handshake
clearall();
-(my $fh, my $session) = tempfile();
+($fh, $session) = tempfile();
$proxy->serverconnects(2);
$proxy->clientflags("-sess_out ".$session." -no_ticket");
$proxy->start();
@@ -117,50 +135,45 @@ $proxy->clientstart();
checkmessages(5, "Session resumption with ticket capable client without a "
."ticket", 1, 1, 1, 0);
-sub checkmessages()
+sub checkmessages($$$$$$)
{
my ($testno, $testname, $testch, $testsh, $testtickseen, $testhand) = @_;
- foreach my $message (@{$proxy->message_list}) {
- if ($message->mt == TLSProxy::Message::MT_CLIENT_HELLO
+ subtest $testname => sub {
+
+ foreach my $message (@{$proxy->message_list}) {
+ if ($message->mt == TLSProxy::Message::MT_CLIENT_HELLO
|| $message->mt == TLSProxy::Message::MT_SERVER_HELLO) {
- #Get the extensions data
- my %extensions = %{$message->extension_data};
- if (defined
+ #Get the extensions data
+ my %extensions = %{$message->extension_data};
+ if (defined
$extensions{TLSProxy::ClientHello::EXT_SESSION_TICKET}) {
- if ($message->mt == TLSProxy::Message::MT_CLIENT_HELLO) {
- $chellotickext = 1;
- } else {
- $shellotickext = 1;
- }
- }
- } elsif ($message->mt == TLSProxy::Message::MT_CLIENT_KEY_EXCHANGE) {
- #Must be doing a full handshake
- $fullhand = 1;
- } elsif ($message->mt == TLSProxy::Message::MT_NEW_SESSION_TICKET) {
- $ticketseen = 1;
- }
- }
+ if ($message->mt == TLSProxy::Message::MT_CLIENT_HELLO) {
+ $chellotickext = 1;
+ } else {
+ $shellotickext = 1;
+ }
+ }
+ } elsif ($message->mt == TLSProxy::Message::MT_CLIENT_KEY_EXCHANGE) {
+ #Must be doing a full handshake
+ $fullhand = 1;
+ } elsif ($message->mt == TLSProxy::Message::MT_NEW_SESSION_TICKET) {
+ $ticketseen = 1;
+ }
+ }
- TLSProxy::Message->success or die "FAILED: $testname: Hanshake failed "
- ."(Test $testno)\n";
- if (($testch && !$chellotickext) || (!$testch && $chellotickext)) {
- die "FAILED: $testname: ClientHello extension Session Ticket check "
- ."failed (Test $testno)\n";
- }
- if (($testsh && !$shellotickext) || (!$testsh && $shellotickext)) {
- die "FAILED: $testname: ServerHello extension Session Ticket check "
- ."failed (Test $testno)\n";
- }
- if (($testtickseen && !$ticketseen) || (!$testtickseen && $ticketseen)) {
- die "FAILED: $testname: Session Ticket message presence check failed "
- ."(Test $testno)\n";
- }
- if (($testhand && !$fullhand) || (!$testhand && $fullhand)) {
- die "FAILED: $testname: Session Ticket full handshake check failed "
- ."(Test $testno)\n";
+ plan tests => 5;
+
+ ok(TLSProxy::Message->success, "Hanshake");
+ ok(($testch && $chellotickext) || (!$testch && !$chellotickext),
+ "ClientHello extension Session Ticket check");
+ ok(($testsh && $shellotickext) || (!$testsh && !$shellotickext),
+ "ServerHello extension Session Ticket check");
+ ok(($testtickseen && $ticketseen) || (!$testtickseen && !$ticketseen),
+ "Session Ticket message presence check");
+ ok(($testhand && $fullhand) || (!$testhand && !$fullhand),
+ "Session Ticket full handshake check");
}
- print "SUCCESS: $testname (Test#$testno)\n";
}
sub clearall()