mirror of
				https://github.com/drwetter/testssl.sh.git
				synced 2025-10-31 22:05:26 +01:00 
			
		
		
		
	Update to newest template
* die statement if testssl.sh cannot be found from the current path * comment everything out for JSON * don't repeat the pattern, use a variable * use "speaking" variable names
This commit is contained in:
		| @@ -9,37 +9,43 @@ use strict; | |||||||
| use Test::More; | use Test::More; | ||||||
| use Data::Dumper; | use Data::Dumper; | ||||||
| # use JSON; | # use JSON; | ||||||
|  | # if we need JSON we need to comment this and the lines below in | ||||||
|  |  | ||||||
| my $tests = 0; | my $tests = 0; | ||||||
|  | my $prg="./testssl.sh"; | ||||||
| my $check2run ="-p -s -P --pfs -S -h -U -q --ip=one --color 0"; | my $check2run ="-p -s -P --pfs -S -h -U -q --ip=one --color 0"; | ||||||
| my $uri=""; | my $uri=""; | ||||||
| my $socketout=""; | my $socket_out=""; | ||||||
| my $opensslout=""; | my $openssl_out=""; | ||||||
|  | # Blacklists we use to trigger an error: | ||||||
|  | my $socket_regex_bl='(e|E)rror|\.\/testssl\.sh: line |(f|F)atal'; | ||||||
|  | my $openssl_regex_bl='(e|E)rror|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem'; | ||||||
|  |  | ||||||
|  | # my $socket_json=""; | ||||||
|  | # my $openssl_json=""; | ||||||
| # $check2run="--jsonfile tmp.json $check2run"; | # $check2run="--jsonfile tmp.json $check2run"; | ||||||
|  |  | ||||||
|  | die "Unable to open $prg" unless -f $prg; | ||||||
|  |  | ||||||
| $uri="google.com"; | $uri="google.com"; | ||||||
|  |  | ||||||
| unlink "tmp.json"; | # unlink "tmp.json"; | ||||||
| printf "\n%s\n", "Baseline unit test IPv4 via sockets --> $uri ..."; | printf "\n%s\n", "Baseline unit test IPv4 via sockets --> $uri ..."; | ||||||
| $socketout = `./testssl.sh $check2run $uri 2>&1`; | $socket_out = `./testssl.sh $check2run $uri 2>&1`; | ||||||
| # my $socket = json('tmp.json'); | # $socket_json = json('tmp.json'); | ||||||
| unlike($socketout, qr/(e|E)rror|\.\/testssl\.sh: line |(f|F)atal/, ""); | unlike($socket_out, qr/$socket_regex_bl/, ""); | ||||||
| $tests++; | $tests++; | ||||||
|  |  | ||||||
|  | # unlink "tmp.json"; | ||||||
| unlink "tmp.json"; |  | ||||||
| printf "\n%s\n", "Baseline unit test IPv4 via OpenSSL --> $uri ..."; | printf "\n%s\n", "Baseline unit test IPv4 via OpenSSL --> $uri ..."; | ||||||
| $opensslout = `./testssl.sh $check2run --ssl-native $uri 2>&1`; | $openssl_out = `./testssl.sh --ssl-native $check2run $uri 2>&1`; | ||||||
| # my $openssl = json('tmp.json'); | # $openssl_json = json('tmp.json'); | ||||||
| # This happens with Google only, so we white list a pattern here: | # With Google only we encounter an error as they return a 0 char with openssl, so we white list this pattern here: | ||||||
| $opensslout =~ s/testssl.*warning: command substitution: ignored null byte in input\n//g; | $openssl_out =~ s/testssl.*warning: command substitution: ignored null byte in input\n//g; | ||||||
| unlike($opensslout, qr/(e|E)rror|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem/, ""); | unlike($openssl_out, qr/$openssl_regex_bl/, ""); | ||||||
| $tests++; | $tests++; | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| done_testing($tests); | done_testing($tests); | ||||||
| unlink "tmp.json"; | unlink "tmp.json"; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -11,33 +11,43 @@ use strict; | |||||||
| use Test::More; | use Test::More; | ||||||
| use Data::Dumper; | use Data::Dumper; | ||||||
| # use JSON; | # use JSON; | ||||||
|  | # if we need JSON we need to comment this and the lines below in | ||||||
|  |  | ||||||
| my $tests = 0; | my $tests = 0; | ||||||
|  | my $prg="./testssl.sh"; | ||||||
| my $check2run ="-p -s -P --pfs -S -h -U -q --ip=one --color 0"; | my $check2run ="-p -s -P --pfs -S -h -U -q --ip=one --color 0"; | ||||||
| my $uri=""; | my $uri=""; | ||||||
| my $socketout=""; | my $socket_out=""; | ||||||
| my $opensslout=""; | my $openssl_out=""; | ||||||
|  | # Blacklists we use to trigger an error: | ||||||
|  | my $socket_regex_bl='(e|E)rror|\.\/testssl\.sh: line |(f|F)atal'; | ||||||
|  | my $openssl_regex_bl='(e|E)rror|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem'; | ||||||
|  |  | ||||||
|  | # my $socket_json=""; | ||||||
|  | # my $openssl_json=""; | ||||||
| # $check2run="--jsonfile tmp.json $check2run"; | # $check2run="--jsonfile tmp.json $check2run"; | ||||||
|  |  | ||||||
|  | die "Unable to open $prg" unless -f $prg; | ||||||
|  |  | ||||||
| $uri="testssl.net"; | $uri="testssl.net"; | ||||||
|  |  | ||||||
| unlink "tmp.json"; | # unlink "tmp.json"; | ||||||
| printf "\n%s\n", "Baseline unit test IPv6 via sockets --> $uri ..."; | printf "\n%s\n", "Baseline unit test IPv6 via sockets --> $uri ..."; | ||||||
| $socketout = `./testssl.sh $check2run -6 $uri 2>&1`; | $socket_out = `./testssl.sh $check2run -6 $uri 2>&1`; | ||||||
| # my $socket = json('tmp.json'); | # $socket_json = json('tmp.json'); | ||||||
| unlike($socketout, qr/(e|E)rror|\.\/testssl\.sh: line |(f|F)atal/, ""); | unlike($socket_out, qr/$socket_regex_bl/, ""); | ||||||
| $tests++; | $tests++; | ||||||
|  |  | ||||||
| unlink "tmp.json"; | # unlink "tmp.json"; | ||||||
| printf "\n%s\n", "Baseline unit test IPv6 via OpenSSL --> $uri ..."; | printf "\n%s\n", "Baseline unit test IPv6 via OpenSSL --> $uri ..."; | ||||||
| $opensslout = `./testssl.sh --ssl-native $check2run -6 $uri 2>&1`; | $openssl_out = `./testssl.sh --ssl-native $check2run -6 $uri 2>&1`; | ||||||
| # my $openssl = json('tmp.json'); | # $openssl_json = json('tmp.json'); | ||||||
| $opensslout =~ s/testssl.*warning: command substitution: ignored null byte in input\n//g; | # With Google only we encounter an error as they return a 0 char with openssl, so we white list this pattern here: | ||||||
| unlike($opensslout, qr/(e|E)rror|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem/, ""); | $openssl_out =~ s/testssl.*warning: command substitution: ignored null byte in input\n//g; | ||||||
|  | unlike($openssl_out, qr/$openssl_regex_bl/, ""); | ||||||
| $tests++; | $tests++; | ||||||
|  |  | ||||||
|  |  | ||||||
| done_testing($tests); | done_testing($tests); | ||||||
| unlink "tmp.json"; | unlink "tmp.json"; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,51 +8,56 @@ | |||||||
| use strict; | use strict; | ||||||
| use Test::More; | use Test::More; | ||||||
| use Data::Dumper; | use Data::Dumper; | ||||||
| use JSON; | # use JSON; | ||||||
|  | # if we need JSON we need to comment this and the lines below in | ||||||
|  |  | ||||||
| my $tests = 0; | my $tests = 0; | ||||||
|  | my $prg="./testssl.sh"; | ||||||
| my $check2run ="--client-simulation -q --ip=one --color 0"; | my $check2run ="--client-simulation -q --ip=one --color 0"; | ||||||
| my $uri=""; | my $uri=""; | ||||||
| my $socketout=""; | my $socket_out=""; | ||||||
| my $opensslout=""; | my $openssl_out=""; | ||||||
|  | # Blacklists we use to trigger an error: | ||||||
|  | my $socket_regex_bl='(e|E)rror|\.\/testssl\.sh: line |(f|F)atal'; | ||||||
|  | my $openssl_regex_bl='(e|E)rror|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem'; | ||||||
|  |  | ||||||
|  | # my $socket_json=""; | ||||||
|  | # my $openssl_json=""; | ||||||
| # $check2run="--jsonfile tmp.json $check2run"; | # $check2run="--jsonfile tmp.json $check2run"; | ||||||
|  |  | ||||||
|  | die "Unable to open $prg" unless -f $prg; | ||||||
|  |  | ||||||
| $uri="google.com"; | $uri="google.com"; | ||||||
|  |  | ||||||
| unlink "tmp.json"; | # unlink "tmp.json"; | ||||||
| printf "\n%s\n", "Client simulations unit test via sockets --> $uri ..."; | printf "\n%s\n", "Client simulations unit test via sockets --> $uri ..."; | ||||||
| $socketout = `./testssl.sh $check2run $uri`; | $socket_out = `./testssl.sh $check2run $uri 2>&1`; | ||||||
| # my $socket = json('tmp.json'); | # $socket_json = json('tmp.json'); | ||||||
| #FIXME: This comparison is maybe not sufficient yet: | unlike($socket_out, qr/$socket_regex_bl/, ""); | ||||||
| unlike($socketout, qr/(e|E)rror|(f|F)atal/, ""); |  | ||||||
| $tests++; | $tests++; | ||||||
|  |  | ||||||
|  | # unlink "tmp.json"; | ||||||
| unlink "tmp.json"; |  | ||||||
| printf "\n%s\n", "Client simulations unit test via OpenSSL --> $uri ..."; | printf "\n%s\n", "Client simulations unit test via OpenSSL --> $uri ..."; | ||||||
| $opensslout = `./testssl.sh $check2run --ssl-native $uri`; | $openssl_out = `./testssl.sh $check2run --ssl-native $uri 2>&1`; | ||||||
| # my $openssl = json('tmp.json'); | # $openssl_json = json('tmp.json'); | ||||||
| #FIXME: This comparison is maybe sufficient yet: | unlike($openssl_out, qr/$openssl_regex_bl/, ""); | ||||||
| unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, ""); |  | ||||||
| $tests++; | $tests++; | ||||||
|  |  | ||||||
|  |  | ||||||
| $uri="smtp-relay.gmail.com:587"; | $uri="smtp-relay.gmail.com:587"; | ||||||
|  |  | ||||||
| unlink "tmp.json"; | # unlink "tmp.json"; | ||||||
| printf "\n%s\n", "STARTTLS: Client simulations unit test via sockets --> $uri ..."; | printf "\n%s\n", "STARTTLS: Client simulations unit test via sockets --> $uri ..."; | ||||||
| $socketout = `./testssl.sh $check2run -t smtp $uri`; | $socket_out = `./testssl.sh $check2run -t smtp $uri 2>&1`; | ||||||
| # my $socket = json('tmp.json'); | # $socket_json = json('tmp.json'); | ||||||
| unlike($socketout, qr/(e|E)rror|(f|F)atal/, ""); | unlike($socket_out, qr/$socket_regex_bl/, ""); | ||||||
| $tests++; | $tests++; | ||||||
|  |  | ||||||
| unlink "tmp.json"; | # unlink "tmp.json"; | ||||||
| printf "\n%s\n", "STARTTLS: Client simulations unit test via OpenSSL --> $uri ..."; | printf "\n%s\n", "STARTTLS: Client simulations unit test via OpenSSL --> $uri ..."; | ||||||
| $opensslout = `./testssl.sh --ssl-native $check2run -t smtp $uri`; | $openssl_out = `./testssl.sh --ssl-native $check2run -t smtp $uri 2>&1`; | ||||||
| # my $openssl = json('tmp.json'); | # $openssl_json = json('tmp.json'); | ||||||
| unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, ""); | unlike($openssl_out, qr/$openssl_regex_bl/, ""); | ||||||
| $tests++; | $tests++; | ||||||
|  |  | ||||||
| done_testing($tests); | done_testing($tests); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Dirk Wetter
					Dirk Wetter