Sha256: 2e8047fc266e263d77758192f3ffbd55a21310177f26ccb1ca347ab548e51a16

Contents?: true

Size: 1.45 KB

Versions: 12

Compression:

Stored size: 1.45 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" => "node01",
        "ssl" => true,
        "ssl_certificate_verification" => false
      }
      next LogStash::Outputs::ElasticSearch.new(settings)
    end

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

    it "print a warning" do
      expect(subject.logger).to receive(:warn)
      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(::Elasticsearch::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

12 entries across 12 versions & 1 rubygems

Version Path
logstash-output-elasticsearch-2.7.1-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-3.0.2-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-3.0.1-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-3.0.0 spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.7.0-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.6.2-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.6.1-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.6.0-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.5.5-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.5.3-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.5.2-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.5.1-java spec/unit/outputs/elasticsearch_ssl_spec.rb