4
unless(grep /blib/, @INC) {
6
@INC = '../lib' if -d '../lib';
10
BEGIN { plan tests => 5}
12
use vars qw($agent_port $comm $agent_host $bad_auth_pass $auth_pass $sec_name $bad_sec_name $bad_version $bad_priv_pass $priv_pass);
13
require "t/startagent.pl";
17
# create list of varbinds for GETS, val field can be null or omitted
18
my $vars = new SNMP::VarList (
19
['sysDescr', '0', ''],
29
#########################== 1 ===#########################################
30
# Create a bogus session, undef means the host can't be found.
31
# removed! this test can hang for a long time if DNS is not functioning
32
# my $s1 = new SNMP::Session (DestHost => $bad_host );
35
#####################== 2 ====############################################
38
new SNMP::Session (DestHost=>$agent_host, Community=>$comm,
39
RemotePort=>$agent_port);
41
######################== 3 ==== ##########################################
43
# Fire up a V3 session
44
my $s3 = new SNMP::Session (Version => 3 , RemotePort => $agent_port,
45
SecName => $sec_name );
47
#print STDERR "Error string1 = $s3->{ErrorStr}:$s3->{ErrorInd}\n";
49
#####################=== 4 ====###########################################
50
#create a V3 session by setting an IP address/port not running an agent
51
my $s4 = new SNMP::Session (Version => 3, RemotePort => 1002, Retries => 0);
52
# engineId discovery should fail resulting in session creation failure (undef)
54
#print STDERR "Error string1 = $s4->{ErrorStr}:$s4->{ErrorInd}\n";
56
###################### 5 ###########################################
57
#create a session with bad version
58
my $s5 = new SNMP::Session (Version=>$bad_version);
61
######################## 6 ########################################
62
#Test for v3 session creation success
63
my $s6 = new SNMP::Session (Version => 3, RemotePort => $agent_port,
64
SecLevel => 'authPriv',
66
PrivPass => $priv_pass,
67
AuthPass => $auth_pass);
69
#print STDERR "Error string2 = $s6->{ErrorStr}:$s6->{ErrorInd}\n";
71
##################### 7 ############################################