summaryrefslogtreecommitdiff
path: root/testing/fulltests/tls/S300tlsperl.pl
blob: 3ea7c0bcf3080c996e514eb36111593af059782a (plain)
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
47
48
49
50
51
52
53
54
#!/usr/bin/perl

BEGIN {
    if (exists($ENV{'srcdir'})) {
	push @INC, "$ENV{'srcdir'}/testing/fulltests/support";
    } elsif (-d "fulltests/support") {
	push @INC, "fulltests/support";
    } elsif (-d "../support") {
	push @INC, "../support";
    }
}
use NetSNMPTest;
use Test;
use SNMP;

my $test = new NetSNMPTest(agentaddress => $agentaddress);

$test->require_feature($feature);

my $netsnmpcert = "$ENV{'srcdir'}/local/net-snmp-cert -I -C $test->{'dir'}";

system("$netsnmpcert gencert -I -t snmpd > /dev/null 2>&1");
system("$netsnmpcert gencert -I -t snmpapp --cn snmpapp > /dev/null 2>&1");
system("$netsnmpcert gencert -I -t perl --cn perl > /dev/null 2>&1");

my $fp = `$netsnmpcert showcerts --fingerprint --brief perl`;
chomp($fp);
print "# using local fp: $fp\n";

plan(tests => 2);
$test->config_agent("syscontact itworked");
$test->config_agent("rwuser -s tsm perl");
$test->config_agent("certSecName 100 snmpapp --cn");
$test->config_agent("certSecName 101 $fp --cn");

$test->DIE("failed to start the agent") if (!$test->start_agent(" -Dtls,ssl,tsm,cert:map"));

# now create a session to test things with
my $session = new SNMP::Session(DestHost => $test->{'agentaddress'},
				TheirIdentity => 'snmpd',
			        OurIdentity => 'perl');

ok(ref($session), 'SNMP::Session', "created a session");

######################################################################
# GET test
if (ref($session) eq 'SNMP::Session') {
    my $value = $session->get('sysContact.0');
    ok($value, 'itworked');
}

######################################################################
# cleanup
$test->stop_agent();