Restore check that the MIB leaf is accessible when validating AUTOLOAD method calls
Restore corresponding test Move live snmp_connect_ip() test to 10_remote_snmplabs.t so that tests requiring Internet access are within one file
This commit is contained in:
@@ -4625,7 +4625,8 @@ sub _validate_autoload_method {
|
||||
# If we were given a fully qualified OID because we don't have the MIB
|
||||
# file, it will translate above but we won't be able to check access so
|
||||
# skip the check and return
|
||||
if ($access && $method =~ /^set/ && $access !~ /Write|Create/) {
|
||||
if ($access && ($method =~ /^set/ && $access !~ /Write|Create/)
|
||||
|| ($method !~ /^set/ && $access eq 'NoAccess')) {
|
||||
|
||||
print
|
||||
"SNMP::Info::_validate_autoload_method($attr : $oid) Not accessable for requested operation.\n"
|
||||
|
||||
@@ -29,6 +29,9 @@ ok((!defined $info->error()), 'No error on initial connection');
|
||||
like($info->name(), qr/\w+/, 'name is "new system name"');
|
||||
is($info->class(), 'SNMP::Info::Layer3::NetSNMP', 'class is Layer3::NetSNMP');
|
||||
|
||||
is($info->snmp_connect_ip('demo.snmplabs.com', 2, 'public'),
|
||||
1, 'Connect to demo.snmplabs.com returns 1');
|
||||
|
||||
done_testing;
|
||||
|
||||
sub _build_mibdirs {
|
||||
|
||||
@@ -1173,7 +1173,6 @@ sub load_all : Tests(6) {
|
||||
'.1.3.6.1.2.1.2.2.1.3' => {1 => 24, 2 => 6, 3 => 6},
|
||||
'.1.3.6.1.2.1.2.2.1.4' => {1 => 1500, 2 => 1514, 3 => 1514},
|
||||
'.1.3.6.1.2.1.2.2.1.5' => {1 => 0, 2 => 100000000, 3 => 1000000000,},
|
||||
'.1.3.6.1.2.1.31.1.1.1.1' => {1 => 'system', 2 => '1/3/1', 3 => '1/3/2'},
|
||||
'.1.3.6.1.2.1.31.1.1.1.15' => {1 => 0, 2 => 100, 3 => 1000,},
|
||||
};
|
||||
|
||||
@@ -1189,7 +1188,6 @@ sub load_all : Tests(6) {
|
||||
'i_type' => {1 => 24, 2 => 6, 3 => 6},
|
||||
'i_mtu' => {1 => 1500, 2 => 1514, 3 => 1514},
|
||||
'i_speed' => {1 => 0, 2 => 100000000, 3 => 1000000000,},
|
||||
'i_name' => {1 => 'system', 2 => '1/3/1', 3 => '1/3/2'},
|
||||
'i_speed_high' => {1 => 0, 2 => 100, 3 => 1000,},
|
||||
|
||||
# In base class defined as ifIndex
|
||||
@@ -1441,7 +1439,7 @@ sub private_show_attr : Tests(3) {
|
||||
);
|
||||
}
|
||||
|
||||
sub snmp_connect_ip : Tests(4) {
|
||||
sub snmp_connect_ip : Tests(3) {
|
||||
my $test = shift;
|
||||
|
||||
can_ok($test->{info}, 'snmp_connect_ip');
|
||||
@@ -1451,8 +1449,7 @@ sub snmp_connect_ip : Tests(4) {
|
||||
is($test->{info}->snmp_connect_ip('0.0.0.0', 2, 'public'),
|
||||
undef, 'Connect to zeros returns undef');
|
||||
|
||||
is($test->{info}->snmp_connect_ip('demo.snmplabs.com', 2, 'public'),
|
||||
1, 'Connect to demo.snmplabs.com returns 1');
|
||||
# Live call moved to 10_remote_snmplabs.t
|
||||
}
|
||||
|
||||
sub modify_port_list : Tests(4) {
|
||||
@@ -1593,15 +1590,9 @@ sub private_validate_autoload_method : Tests(8) {
|
||||
q(Func 'ifPromiscuousMode_raw' validates)
|
||||
);
|
||||
};
|
||||
TODO: {
|
||||
local $TODO
|
||||
= "Check MIB access for non set methods in _validate_autoload_method"
|
||||
if 1;
|
||||
|
||||
# Test that not-accessible leaf returns undef IF-MIB::ifStackHigherLayer
|
||||
is($test->{info}->_validate_autoload_method('ifStackHigherLayer'),
|
||||
undef, q(MIB leaf 'ifStackHigherLayer' not-accessible, returns undef));
|
||||
}
|
||||
|
||||
# Test that read-only leaf won't validate set_
|
||||
is($test->{info}->_validate_autoload_method('set_i_lastchange'),
|
||||
|
||||
Reference in New Issue
Block a user