File: 25_client_sims_starttls.t

package info (click to toggle)
testssl.sh 2.9.5-7%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,640 kB
  • sloc: sh: 15,436; perl: 578; makefile: 11
file content (46 lines) | stat: -rwxr-xr-x 1,556 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env perl

use strict;
use Test::More;
use Data::Dumper;
use JSON;

my $tests = 0;

unlink "tmp.json";
pass("Running openssl based client simulations against smtp-relay.gmail.com:587"); $tests++;
my $opensslout = `./testssl.sh --client-simulation --ssl-native -t smtp --jsonfile tmp.json --color 0 smtp-relay.gmail.com:587`;
my $openssl = json('tmp.json');
unlike($opensslout, qr/Running client simulations via sockets/, "Tests didn't run via sockets"); $tests++;

pass("Running socket based client simulations against smtp-relay.gmail.com:587"); $tests++;
unlink "tmp.json";
my $socketout = `./testssl.sh --client-simulation -t smtp --jsonfile tmp.json --color 0 smtp-relay.gmail.com:587`;
my $socket = json('tmp.json');
like($socketout, qr/Running client simulations via sockets/, "Tests ran via sockets"); $tests++;


#my $i = 0;
#foreach my $o ( @$openssl ) {
#	my $s = $$socket[$i];
#	if ( $o->{id} =~ /^client_/ ) {
#		pass("Comparing $o->{id}"); $tests++;
#		cmp_ok($o->{id}, "eq", $s->{id}, "Id's match"); $tests++;
#		cmp_ok($o->{severity}, "eq", $s->{severity}, "Severities match"); $tests++;
#		cmp_ok($o->{finding}, "eq", $s->{finding}, "Findings match"); $tests++;
#	}
#	$i++;
#}

done_testing($tests);
unlink "tmp.json";

sub json($) {
	my $file = shift;
	$file = `cat $file`;
	unlink $file;
	return from_json($file);
}

# problem: 1-4 ok but of limited use: wy should we test whether runs really via sockets or openssl??
# 5-n:     no sense, we know sockets and ssl are diffferent why should we have a unit test comparing those???