Debian Codegraph @

testing/fulltests/perl/NetSNMPTestTransport.pm

raw
1 package NetSNMPTestTransport;
2
3 use strict;
4 use warnings;
5 use NetSNMPTest;
6 use Test;
7 use SNMP;
8
9 our @ISA = qw(NetSNMPTest);
10
11 sub run_tests {
12 my ($self) = @_;
13
14 plan(tests => 2);
15
16 # set it up with a snmpv3 USM user
17 $self->config_agent("createuser testuser MD5 notareallpassword");
18 $self->config_agent("rwuser testuser");
19 $self->config_agent("syscontact itworked");
20
21 $self->DIE("failed to start the agent") if (!$self->start_agent());
22
23 # now create a session to test things with
24 my $session = new SNMP::Session(DestHost => $self->{'agentaddress'},
25 Version => '3',
26 SecName => 'testuser',
27 SecLevel => 'authNoPriv',
28 AuthProto => 'MD5',
29 AuthPass => 'notareallpassword');
30
31 ok(ref($session), 'SNMP::Session', "created a session");
32
33 ######################################################################
34 # GET test
35 if (ref($session) eq 'SNMP::Session') {
36 my $value = $session->get('sysContact.0');
37 ok($value, 'itworked');
38 }
39
40 ######################################################################
41 # cleanup
42 $self->stop_agent();
43 }
44
45
46 1;