Sha256: ff58143264740f709bbaf327b16880563be5d4ceb505fde2f66cecc1124127a6

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

require_relative "../../../spec/es_spec_helper"

describe "SSL option" do
  ["node", "transport"].each do |protocol|
    context "with protocol => #{protocol}" do
      subject do
        require "logstash/outputs/elasticsearch"
        settings = {
          "protocol" => protocol,
          "node_name" => "logstash",
          "cluster" => "elasticsearch",
          "host" => "node01",
          "ssl" => true
        }
        next LogStash::Outputs::ElasticSearch.new(settings)
      end

      it "should fail in register" do
        expect {subject.register}.to raise_error
      end
    end
  end

  context "when using http protocol" do
    protocol = "http"
    context "when using ssl without cert verification" do
      subject do
        require "logstash/outputs/elasticsearch"
        settings = {
          "protocol" => protocol,
          "host" => "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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
logstash-output-elasticsearch-1.0.1-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-1.0.0-java spec/unit/outputs/elasticsearch_ssl_spec.rb
logstash-output-elasticsearch-0.2.9-java spec/unit/outputs/elasticsearch_ssl_spec.rb