From b7f87d9e8202fd41a635ca2930702565fa2bc1f2 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 28 Jan 2018 21:28:21 +0000 Subject: [PATCH] add real snmp test against demo.snmplabs.com --- xt/10_remote_snmplabs.t | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 xt/10_remote_snmplabs.t diff --git a/xt/10_remote_snmplabs.t b/xt/10_remote_snmplabs.t new file mode 100644 index 00000000..910d5a6a --- /dev/null +++ b/xt/10_remote_snmplabs.t @@ -0,0 +1,39 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use Test::More 1.302083; + +use SNMP::Info; +use Path::Class 'dir'; + +my $info = SNMP::Info->new( + AutoSpecify => 1, + DestHost => 'demo.snmplabs.com', + Community => 'public', + Version => 2, + MibDirs => [ _build_mibdirs() ], + IgnoreNetSNMPConf => 1, + #Debug => 1, + #DebugSNMP => 1, +); + +ok($info, 'SNMP::Info instantiated'); +ok((!defined $info->error()), 'No error on initial connection'); + +is($info->name(), 'Reboot', 'name is Reboot'); +is($info->class(), 'SNMP::Info::Layer3::NetSNMP', 'class is Layer3::NetSNMP'); + +done_testing; + +sub _build_mibdirs { + my $home = dir($ENV{HOME}, 'netdisco-mibs'); + return map { dir($home, $_)->stringify } @{ _get_mibdirs_content($home) }; +} + +sub _get_mibdirs_content { + my $home = shift; + my @list = map {s|$home/||; $_} grep {m/[a-z0-9]/} grep {-d} glob("$home/*"); + return \@list; +}