Skip to content

Commit a499233

Browse files
committed
Add unittest for diffrent openssl versions
This adds a unit test to compare a run against google with the supplied openssl version vs /usr/bin/openssl . This would fix #2626. It looks like there are still points to clarify * NPN output is different (bug) * Newer openssl version claims it's ECDH 253 instead of ECDH 256. * Newer openssl version claims for 130x cipher it's ECDH 253, via sockets it´s ECDH/MLKEM. This seems a bug (@dcooper) A todo is also restricing the unit test to the one where openssl is being used. E.g. the ROBOT check and more aren't done with openssl. So there's no value checking this here.
1 parent 17f2a5d commit a499233

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

t/12_diff_opensslversions.t

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env perl
2+
3+
# Baseline diff test against testssl.sh (csv output)
4+
#
5+
# This runs a basic test with the supplied openssl vs /usr/bin/openssl
6+
7+
use strict;
8+
use Test::More;
9+
use Data::Dumper;
10+
use Text::Diff;
11+
12+
my $tests = 0;
13+
my $prg="./testssl.sh";
14+
my $check2run="-q --ip=one --color 0 --csvfile";
15+
my $csvfile="tmp.csv";
16+
my $csvfile2="tmp2.csv";
17+
my $cat_csvfile="";
18+
my $cat_csvfile2="";
19+
my $uri="google.com";
20+
my $diff="";
21+
my $distro_openssl="/usr/bin/openssl";
22+
23+
die "Unable to open $prg" unless -f $prg;
24+
die "Unable to open $distro_openssl" unless -f $distro_openssl;
25+
26+
# Provide proper start conditions
27+
unlink "tmp.csv";
28+
unlink "tmp2.csv";
29+
30+
#1 run
31+
printf "\n%s\n", "Diff test IPv4 with supplied openssl against \"$uri\"";
32+
`$prg $check2run $csvfile $uri 2>&1`;
33+
34+
# 2
35+
printf "\n%s\n", "Diff test IPv4 with $distro_openssl against \"$uri\"";
36+
`$prg $check2run $csvfile2 --openssl=$distro_openssl $uri 2>&1`;
37+
38+
$cat_csvfile = `cat $csvfile`;
39+
$cat_csvfile2 = `cat $csvfile2`;
40+
41+
# Filter for changes that are allowed to occur
42+
$cat_csvfile =~ s/HTTP_clock_skew.*\n//g;
43+
$cat_csvfile2 =~ s/HTTP_clock_skew.*\n//g;
44+
45+
# HTTP time
46+
$cat_csvfile =~ s/HTTP_headerTime.*\n//g;
47+
$cat_csvfile2 =~ s/HTTP_headerTime.*\n//g;
48+
49+
#engine_problem
50+
$cat_csvfile =~ s/"engine_problem.*\n//g;
51+
$cat_csvfile2 =~ s/"engine_problem.*\n//g;
52+
53+
# Nonce in CSP
54+
$cat_csvfile =~ s/.nonce-.* //g;
55+
$cat_csvfile2 =~ s/.nonce-.* //g;
56+
57+
$diff = diff \$cat_csvfile, \$cat_csvfile2;
58+
59+
# Compare the differences -- and print them if there were any
60+
ok( $cat_csvfile eq $cat_csvfile2, "Check whether CSV outputs match" ) or
61+
diag ("\n%s\n", "$diff");
62+
63+
#unlink "tmp.csv";
64+
#unlink "tmp2.csv";
65+
66+
$tests++;
67+
done_testing($tests);
68+
printf "\n";
69+
70+
71+
# vim:ts=5:sw=5:expandtab
72+

0 commit comments

Comments
 (0)