Sha256: f66f0f24f07973200af21527c12ec220ca7092b4dad9b7689ee82765ba879d58

Contents?: true

Size: 1.43 KB

Versions: 8

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

8 entries across 8 versions & 1 rubygems

Version Path
logstash-output-elasticsearch-2.1.2-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.1.1-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.1.0-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.0.0.beta6-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.0.0.beta5-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.0.0.beta4-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.0.0.pre.beta2-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-2.0.0.pre.beta-java spec/unit/outputs/elasticsearch_ssl_spec.rb