Sha256: 8d750c6bd4e4254ec735472f12172f1a78f09cae62a787b4f0dcdb9415af72f1

Contents?: true

Size: 1.53 KB

Versions: 18

Compression:

Stored size: 1.53 KB

Contents

# encoding: utf-8
require 'logstash/devutils/rspec/spec_helper'
require 'logstash/inputs/remote_proc'
require 'net/ssh'
require 'net/ssh/gateway'

describe LogStash::Inputs::RemoteProc do
  let(:config) do
    { 'servers' => [{ 'host' => 'localhost',
                      'port' => 22,
                      'username' => ENV['USER'] }],
      'interval' => 100 }
  end

  let(:queue) { [] }

  before do
    ssh_session = spy('Net::SSH')
    allow(Net::SSH).to receive(:start).with(any_args).and_return(ssh_session)
  end

  it_behaves_like 'an interruptible input plugin' do
  end

  subject { described_class.new(config) }

  context 'when host is reacheable' do
    it '.register' do
      expect { subject.register }.to_not raise_error
    end
  end

  context 'when host is unreacheable' do
    it '.register' do
      rp = described_class.new(
        'servers' => { 'host' => 'not_konown_host' }
      )
      expect { rp.register }.to_not raise_error
    end
  end

  context 'when gateway is provided' do
    it '.register' do
      ssh_gateway = spy('Net::SSH::Gateway')
      expect(Net::SSH::Gateway).to receive(:new).with(any_args)
        .and_return(ssh_gateway)
      rp_gateway = described_class.new(
        'servers' => [{ 'host' => 'localhost',
                        'port' => 22,
                        'username' => ENV['USER'],
                        'gateway_host' => '10.0.0.1',
                        'gateway_port' => 22 }],
        'interval' => 100
      )
      expect { rp_gateway.register }.to_not raise_error
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
logstash-input-remote_proc-0.7.0 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.6.0 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.5.0 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.4.0 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.3.0 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.2.0 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.1.9 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.1.8 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.1.7 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.1.6 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.1.5 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.1.4 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.1.3 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.1.2 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.1.1 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.1.0 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.0.24 spec/inputs/remote_proc_spec.rb
logstash-input-remote_proc-0.0.23 spec/inputs/remote_proc_spec.rb