Sha256: 7c1e470ba3634a7fd7ce9d75acab134733477b4d5120936afb8cadda7633c973

Contents?: true

Size: 1.7 KB

Versions: 15

Compression:

Stored size: 1.7 KB

Contents

require_relative "../../../spec/es_spec_helper"
require 'stud/temporary'

describe "SSL option" do
  context "when using ssl without cert verification" do
    subject do
      require "logstash/outputs/elasticsearch"
      settings = {
        "hosts" => "localhost",
        "ssl" => true,
        "ssl_certificate_verification" => false,
        "pool_max" => 1,
        "pool_max_per_route" => 1
      }
      next LogStash::Outputs::ElasticSearch.new(settings)
    end

    it "should pass the flag to the ES client" do
      expect(::Manticore::Client).to receive(:new) do |args|
        expect(args[:ssl]).to eq(:enabled => true, :verify => false)
      end
      subject.register
    end

    it "should print a warning" do
      disabled_matcher = /You have enabled encryption but DISABLED certificate verification/
      expect(subject.logger).to receive(:warn).with(disabled_matcher).at_least(:once)
      allow(subject.logger).to receive(:warn).with(any_args)
      subject.register
    end
  end

  context "when using ssl with client certificates" do
    let(:keystore_path) { Stud::Temporary.file.path }

    after :each do
      File.delete(keystore_path)
    end

    subject do
      require "logstash/outputs/elasticsearch"
      settings = {
        "hosts" => "node01",
        "ssl" => true,
        "keystore" => keystore_path,
        "keystore_password" => "test"
      }
      next LogStash::Outputs::ElasticSearch.new(settings)
    end

    it "should pass the keystore parameters to the ES client" do
      expect(::Manticore::Client).to receive(:new) do |args|
        expect(args[:ssl]).to include(:keystore => keystore_path, :keystore_password => "test")
      end
      subject.register
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

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