Sha256: 61ecabffae14525ecef67ee1902cc444d3ebd6469415f7d292e3271ade730aa3

Contents?: true

Size: 1.43 KB

Versions: 10

Compression:

Stored size: 1.43 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(: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

10 entries across 10 versions & 1 rubygems

Version Path
logstash-output-elasticsearch-2.5.0-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.4.2-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.4.1-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.4.0-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.3.2-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.3.1-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.3.0-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.2.0-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.1.5-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.1.4-java spec/unit/outputs/elasticsearch_ssl_spec.rb