Sha256: 45a411bb6d8b542500f5f599ae3408f427487e5248f467a3ef0ae696c045597e

Contents?: true

Size: 1.8 KB

Versions: 19

Compression:

Stored size: 1.8 KB

Contents

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

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

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

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

    after do
      subject.close
    end

    context "when specified as a URI" do
      shared_examples("hash conversion") do |hash|
        let(:settings) { super.merge("proxy" => proxy)}
        
        it "should set the proxy to the correct hash value" do
          expect(::Manticore::Client).to have_received(:new) do |options|
            expect(options[:proxy]).to eq(hash)
          end
        end
      end
      
      describe "simple proxy" do
        let(:proxy) { LogStash::Util::SafeURI.new("http://127.0.0.1:1234") }

        include_examples("hash conversion",
          {
            :host => "127.0.0.1",
            :scheme => "http",
            :port => 1234  
          }
        )
      end
      
      
      describe "a secure authed proxy" do
        let(:proxy) { LogStash::Util::SafeURI.new("https://myuser:mypass@127.0.0.1:1234") }

        include_examples("hash conversion",
          {
            :host => "127.0.0.1",
            :scheme => "https",
            :user => "myuser",
            :password => "mypass",
            :port => 1234  
          }
        )
      end
    end

    context "when not specified" do
      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
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
logstash-output-elasticsearch-test-10.3.0-x86_64-linux spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-10.3.0-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-10.2.3-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-10.2.2-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-10.2.1-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-10.2.0-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-10.1.0-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-10.0.2-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-10.0.1-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-9.4.0-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-9.3.2-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-9.3.1-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-9.3.0-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-9.2.4-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-9.2.3-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-9.2.1-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-9.2.0-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-9.1.4-java spec/unit/outputs/elasticsearch_proxy_spec.rb
logstash-output-elasticsearch-9.1.3-java spec/unit/outputs/elasticsearch_proxy_spec.rb