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 Data::Dumper; | ||||
| # use JSON; | ||||
| # if we need JSON we need to comment this and the lines below in | ||||
|  | ||||
| my $tests = 0; | ||||
| my $prg="./testssl.sh"; | ||||
| my $check2run ="-p -s -P --pfs -S -h -U -q --ip=one --color 0"; | ||||
| my $uri=""; | ||||
| my $socketout=""; | ||||
| my $opensslout=""; | ||||
| my $socket_out=""; | ||||
| 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"; | ||||
|  | ||||
| die "Unable to open $prg" unless -f $prg; | ||||
|  | ||||
| $uri="google.com"; | ||||
|  | ||||
| unlink "tmp.json"; | ||||
| # unlink "tmp.json"; | ||||
| printf "\n%s\n", "Baseline unit test IPv4 via sockets --> $uri ..."; | ||||
| $socketout = `./testssl.sh $check2run $uri 2>&1`; | ||||
| # my $socket = json('tmp.json'); | ||||
| unlike($socketout, qr/(e|E)rror|\.\/testssl\.sh: line |(f|F)atal/, ""); | ||||
| $socket_out = `./testssl.sh $check2run $uri 2>&1`; | ||||
| # $socket_json = json('tmp.json'); | ||||
| unlike($socket_out, qr/$socket_regex_bl/, ""); | ||||
| $tests++; | ||||
|  | ||||
|  | ||||
| unlink "tmp.json"; | ||||
| # unlink "tmp.json"; | ||||
| printf "\n%s\n", "Baseline unit test IPv4 via OpenSSL --> $uri ..."; | ||||
| $opensslout = `./testssl.sh $check2run --ssl-native $uri 2>&1`; | ||||
| # my $openssl = json('tmp.json'); | ||||
| # This happens with Google only, so we white list a pattern here: | ||||
| $opensslout =~ 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/, ""); | ||||
| $openssl_out = `./testssl.sh --ssl-native $check2run $uri 2>&1`; | ||||
| # $openssl_json = json('tmp.json'); | ||||
| # With Google only we encounter an error as they return a 0 char with openssl, so we white list this pattern here: | ||||
| $openssl_out =~ s/testssl.*warning: command substitution: ignored null byte in input\n//g; | ||||
| unlike($openssl_out, qr/$openssl_regex_bl/, ""); | ||||
| $tests++; | ||||
|  | ||||
|  | ||||
|  | ||||
| done_testing($tests); | ||||
| unlink "tmp.json"; | ||||
|  | ||||
|   | ||||
| @@ -11,33 +11,43 @@ use strict; | ||||
| use Test::More; | ||||
| use Data::Dumper; | ||||
| # use JSON; | ||||
| # if we need JSON we need to comment this and the lines below in | ||||
|  | ||||
| my $tests = 0; | ||||
| my $prg="./testssl.sh"; | ||||
| my $check2run ="-p -s -P --pfs -S -h -U -q --ip=one --color 0"; | ||||
| my $uri=""; | ||||
| my $socketout=""; | ||||
| my $opensslout=""; | ||||
| my $socket_out=""; | ||||
| 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"; | ||||
|  | ||||
| die "Unable to open $prg" unless -f $prg; | ||||
|  | ||||
| $uri="testssl.net"; | ||||
|  | ||||
| unlink "tmp.json"; | ||||
| # unlink "tmp.json"; | ||||
| printf "\n%s\n", "Baseline unit test IPv6 via sockets --> $uri ..."; | ||||
| $socketout = `./testssl.sh $check2run -6 $uri 2>&1`; | ||||
| # my $socket = json('tmp.json'); | ||||
| unlike($socketout, qr/(e|E)rror|\.\/testssl\.sh: line |(f|F)atal/, ""); | ||||
| $socket_out = `./testssl.sh $check2run -6 $uri 2>&1`; | ||||
| # $socket_json = json('tmp.json'); | ||||
| unlike($socket_out, qr/$socket_regex_bl/, ""); | ||||
| $tests++; | ||||
|  | ||||
| unlink "tmp.json"; | ||||
| # unlink "tmp.json"; | ||||
| printf "\n%s\n", "Baseline unit test IPv6 via OpenSSL --> $uri ..."; | ||||
| $opensslout = `./testssl.sh --ssl-native $check2run -6 $uri 2>&1`; | ||||
| # my $openssl = json('tmp.json'); | ||||
| $opensslout =~ 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/, ""); | ||||
| $openssl_out = `./testssl.sh --ssl-native $check2run -6 $uri 2>&1`; | ||||
| # $openssl_json = json('tmp.json'); | ||||
| # With Google only we encounter an error as they return a 0 char with openssl, so we white list this pattern here: | ||||
| $openssl_out =~ s/testssl.*warning: command substitution: ignored null byte in input\n//g; | ||||
| unlike($openssl_out, qr/$openssl_regex_bl/, ""); | ||||
| $tests++; | ||||
|  | ||||
|  | ||||
| done_testing($tests); | ||||
| unlink "tmp.json"; | ||||
|  | ||||
|   | ||||
| @@ -8,51 +8,56 @@ | ||||
| use strict; | ||||
| use Test::More; | ||||
| 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 $prg="./testssl.sh"; | ||||
| my $check2run ="--client-simulation -q --ip=one --color 0"; | ||||
| my $uri=""; | ||||
| my $socketout=""; | ||||
| my $opensslout=""; | ||||
| my $socket_out=""; | ||||
| 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"; | ||||
|  | ||||
| die "Unable to open $prg" unless -f $prg; | ||||
|  | ||||
| $uri="google.com"; | ||||
|  | ||||
| unlink "tmp.json"; | ||||
| # unlink "tmp.json"; | ||||
| printf "\n%s\n", "Client simulations unit test via sockets --> $uri ..."; | ||||
| $socketout = `./testssl.sh $check2run $uri`; | ||||
| # my $socket = json('tmp.json'); | ||||
| #FIXME: This comparison is maybe not sufficient yet: | ||||
| unlike($socketout, qr/(e|E)rror|(f|F)atal/, ""); | ||||
| $socket_out = `./testssl.sh $check2run $uri 2>&1`; | ||||
| # $socket_json = json('tmp.json'); | ||||
| unlike($socket_out, qr/$socket_regex_bl/, ""); | ||||
| $tests++; | ||||
|  | ||||
|  | ||||
| unlink "tmp.json"; | ||||
| # unlink "tmp.json"; | ||||
| printf "\n%s\n", "Client simulations unit test via OpenSSL --> $uri ..."; | ||||
| $opensslout = `./testssl.sh $check2run --ssl-native $uri`; | ||||
| # my $openssl = json('tmp.json'); | ||||
| #FIXME: This comparison is maybe sufficient yet: | ||||
| unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, ""); | ||||
| $openssl_out = `./testssl.sh $check2run --ssl-native $uri 2>&1`; | ||||
| # $openssl_json = json('tmp.json'); | ||||
| unlike($openssl_out, qr/$openssl_regex_bl/, ""); | ||||
| $tests++; | ||||
|  | ||||
|  | ||||
| $uri="smtp-relay.gmail.com:587"; | ||||
|  | ||||
| unlink "tmp.json"; | ||||
| # unlink "tmp.json"; | ||||
| printf "\n%s\n", "STARTTLS: Client simulations unit test via sockets --> $uri ..."; | ||||
| $socketout = `./testssl.sh $check2run -t smtp $uri`; | ||||
| # my $socket = json('tmp.json'); | ||||
| unlike($socketout, qr/(e|E)rror|(f|F)atal/, ""); | ||||
| $socket_out = `./testssl.sh $check2run -t smtp $uri 2>&1`; | ||||
| # $socket_json = json('tmp.json'); | ||||
| unlike($socket_out, qr/$socket_regex_bl/, ""); | ||||
| $tests++; | ||||
|  | ||||
| unlink "tmp.json"; | ||||
| # unlink "tmp.json"; | ||||
| printf "\n%s\n", "STARTTLS: Client simulations unit test via OpenSSL --> $uri ..."; | ||||
| $opensslout = `./testssl.sh --ssl-native $check2run -t smtp $uri`; | ||||
| # my $openssl = json('tmp.json'); | ||||
| unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, ""); | ||||
| $openssl_out = `./testssl.sh --ssl-native $check2run -t smtp $uri 2>&1`; | ||||
| # $openssl_json = json('tmp.json'); | ||||
| unlike($openssl_out, qr/$openssl_regex_bl/, ""); | ||||
| $tests++; | ||||
|  | ||||
| done_testing($tests); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Dirk Wetter
					Dirk Wetter