Sha256: f23450708a729c3f43cd3c4270048ecf65d7a90eba28560d91dc28f942473d98

Contents?: true

Size: 1.63 KB

Versions: 14

Compression:

Stored size: 1.63 KB

Contents

require_relative "../../../spec/es_spec_helper"
require 'stud/temporary'
require "logstash/outputs/elasticsearch"

describe "Proxy option" do
  let(:settings) {
    {
      "hosts" => "node01",
      "proxy" => proxy
    }
  }
  subject {
    LogStash::Outputs::ElasticSearch.new(settings)
  }

  before do
    allow(::Manticore::Client).to receive(:new).with(any_args)
  end

  describe "valid configs" do
    before do
      subject.register
    end

    context "when specified as a string" do
      let(:proxy) { "http://127.0.0.1:1234" }

      it "should set the proxy to the exact value" do
        expect(::Manticore::Client).to have_received(:new) do |options|
          expect(options[:proxy]).to eql(proxy)
        end
      end
    end

    context "when specified as a hash" do
      let(:proxy) { {"hosts" => "127.0.0.1", "protocol" => "http"} }

      it "should pass through the proxy values as symbols" do
        expected = {:hosts => proxy["hosts"], :protocol => proxy["protocol"]}
        expect(::Manticore::Client).to have_received(:new) do |options|
          expect(options[:proxy]).to eql(expected)
        end
      end
    end

    context "when not specified" do
      let(:proxy) { nil }
      
      it "should not send the proxy option to manticore" do
        expect(::Manticore::Client).to have_received(:new) do |options|
          expect(options).not_to include(:proxy)
        end
      end
    end
  end

  describe "invalid configs" do
    let(:proxy) { ["bad", "stuff"] }

    it "should have raised an exception" do
      expect {
        subject.register
      }.to raise_error(LogStash::ConfigurationError)
    end
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
logstash-output-elasticsearch-5.3.5-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-5.3.4-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-5.2.1-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-5.3.3-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-5.3.2-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-5.3.1-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-5.3.0-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-5.2.0-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-5.1.2-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-5.1.1-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-5.1.0-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-4.1.3-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-4.1.2-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-4.1.1-java spec/unit/outputs/elasticsearch_proxy_spec.rb