4 unless(grep /blib/, @INC) {
6 @INC = '../lib' if -d '../lib';
10 BEGIN { $n = 10; plan tests => $n }
12 use vars qw($agent_port $comm $comm2 $trap_port $agent_host $sec_name $priv_pass $auth_pass $bad_name);
13 require 't/startagent.pl';
17 my $enterprise = '.1.3.6.1.2.1.1.1.0';
18 my $generic = 'specific';
21 ###################### 1 #############################
22 # Fire up a trap session.
24 new SNMP::Session (DestHost=>$agent_host,Version=>1,Community=>$comm,RemotePort=>$trap_port);
27 ########################## 2 ####################################
29 $res = $s1->trap(enterprise => $enterprise, agent=>$agent_host, generic=>$generic,[[sysContact, 0, 'root@localhost'], [sysLocation, 0, 'here']] );
30 ok($res =~ /^0 but true/);
32 ########################### 3 #############################
33 # test with wrong varbind
34 $res = $s1->trap([[$bad_name, 0, 'root@localhost'], [sysLocation, 0, 'here']] );
35 #print("res is $res\n");
37 #########################################################
40 ########################## 4 ############################
41 # Fire up a v2 trap session.
43 new SNMP::Session (Version=>2, DestHost=>$agent_host,Community=>$comm2,RemotePort=>$trap_port);
45 ######################### 5 ###########################
47 $res = $s2->trap(uptime=>200, trapoid=>'coldStart',[[sysContact, 0, 'root@localhost'], [sysLocation, 0, 'here']] );
48 #print("res is $res\n");
49 ok($res =~ /^0 but true/);
50 ########################## 6 ##########################
51 # no trapoid and uptime given. Should take defaults...
52 my $ret = $s2->trap([[sysContact, 0, 'root@localhost'], [sysLocation, 0, 'here']] );
53 #print("res is $ret\n");
56 #########################################################
59 ######################## 7 ############################
60 # Fire up a v3 trap session.
61 my $s3 = new SNMP::Session(Version=>3, DestHost=> $agent_host, RemotePort=>$trap_port, SecName => $sec_name);
64 ######################## 8 ###########################
65 $res = $s3->inform(uptime=>111, trapoid=>'coldStart', [[sysContact, 0, 'root@localhost'], [sysLocation, 0, 'here']] );
66 ok($res =~ /^0 but true/);
68 #################### 9 #####################
69 # Fire up a v3 trap session.
70 $s3 = new SNMP::Session(Version=>3, DestHost=> $agent_host, RemotePort=>$trap_port, SecName => $sec_name, SecLevel => authPriv, AuthPass => $auth_pass, PrivPass => $priv_pass);
73 ######################## 10 ###########################
74 $res = $s3->inform(uptime=>111, trapoid=>'coldStart', [[sysContact, 0, 'root@localhost'], [sysLocation, 0, 'here']] );
76 ok($res =~ /^0 but true/);