summaryrefslogtreecommitdiff
path: root/testing/fulltests/perl/NetSNMPTestTransport.pm
diff options
context:
space:
mode:
Diffstat (limited to 'testing/fulltests/perl/NetSNMPTestTransport.pm')
-rw-r--r--testing/fulltests/perl/NetSNMPTestTransport.pm54
1 files changed, 54 insertions, 0 deletions
diff --git a/testing/fulltests/perl/NetSNMPTestTransport.pm b/testing/fulltests/perl/NetSNMPTestTransport.pm
new file mode 100644
index 0000000..38bcfee
--- /dev/null
+++ b/testing/fulltests/perl/NetSNMPTestTransport.pm
@@ -0,0 +1,54 @@
+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";
+ }
+}
+
+package NetSNMPTestTransport;
+
+use NetSNMPTest;
+use Test;
+use SNMP;
+
+our @ISA = qw(NetSNMPTest);
+
+sub run_tests {
+ my ($self) = @_;
+
+ plan(tests => 2);
+
+ # set it up with a snmpv3 USM user
+ $self->config_agent("createuser testuser MD5 notareallpassword");
+ $self->config_agent("rwuser testuser");
+ $self->config_agent("syscontact itworked");
+
+ $self->DIE("failed to start the agent") if (!$self->start_agent());
+
+ # now create a session to test things with
+ my $session = new SNMP::Session(DestHost => $self->{'agentaddress'},
+ Version => '3',
+ SecName => 'testuser',
+ SecLevel => 'authNoPriv',
+ AuthProto => 'MD5',
+ AuthPass => 'notareallpassword');
+
+ ok(ref($session), 'SNMP::Session', "created a session");
+
+ ######################################################################
+ # GET test
+ if (ref($session) eq 'SNMP::Session') {
+ $value = $session->get('sysContact.0');
+ ok($value, 'itworked');
+ }
+
+ ######################################################################
+ # cleanup
+ $self->stop_agent();
+}
+
+
+1;