Sha256: 4d42fc8c5f032d7c2967f8c108bbc58f6354ea03c3f8c3722dbb96b45c7e264b

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

require 'snmpjr'
require 'snmpjr/response'
require 'snmpjr/session_v3'

describe "snmpjr for snmp v3" do

  describe 'WALK' do
    subject { Snmpjr.new(Snmpjr::Version::V3) }

    context 'when the host is reachable' do
      before do
        subject.configure do |config|
          config.host = 'demo.snmplabs.com'
          config.port = 161
          config.context = '80004fb805636c6f75644dab22cc'
          config.user = 'usr-none-none'
        end
      end

      it 'can perform a simple synchronous walk request on an snmp agent' do
        response = subject.walk '1.3.6.1.2.1.1'
        expect(response.count).to eq 11
        expect(response.first.to_h).to eq(
          { oid: '1.3.6.1.2.1.1.1.0', value: 'SunOS zeus.snmplabs.com 4.1.3_U1 1 sun4m', type: 'OCTET STRING' }
        )
      end

      context "when a non existent subtree is walked" do
        it 'returns an empty array' do
          expect(subject.walk '1.3.6.1.5').to eq []
        end
      end
    end

    context 'when the host is unreachable' do
      before do
        subject.configure do |config|
          config.host = 'demo.snmplabs.com'
          config.port = 161
          config.context = '80004fb805636c6f75644dab22cc'
          config.user = 'usr-sha-aes256'
          config.authentication 'SHA', 'authkey1'
          config.privacy 'AES256', 'privkey1'
          config.timeout = 50
        end
      end

      it 'the request times out after 5 seconds' do
        expect{
          subject.walk '1.3.6.1.2.1.1'
        }.to raise_error(Snmpjr::TargetTimeoutError)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snmpjr-0.3.3-java spec/integration/snmp_v3/snmpjr_walk_spec.rb