Sha256: 1156a8f1c8f817abf12c7f624520733a302555014f98ec835818c9cf289d9202

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

require "logstash/outputs/elasticsearch"
require "logstash/outputs/elasticsearch/http_client"
require "logstash/outputs/elasticsearch/http_client_builder"

describe LogStash::Outputs::ElasticSearch::HttpClientBuilder do
  describe "auth setup with url encodable passwords" do
    let(:klass) { LogStash::Outputs::ElasticSearch::HttpClientBuilder }
    let(:user) { "foo@bar"}
    let(:password) {"bazblah" }
    let(:password_secured) do
      secured = double("password")
      allow(secured).to receive(:value).and_return(password)
      secured
    end
    let(:options) { {"user" => user, "password" => password} }
    let(:logger) { mock("logger") }
    let(:auth_setup) { klass.setup_basic_auth(double("logger"), {"user" => user, "password" => password_secured}) }

    it "should return the user verbatim" do
      expect(auth_setup[:user]).to eql(user)
    end

    it "should return the password verbatim" do
      expect(auth_setup[:password]).to eql(password)
    end
    
    context "passwords that need escaping" do
      let(:password) { "foo@bar#" }
      
      it "should escape the password" do
        expect(auth_setup[:password]).to eql("foo%40bar%23")
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
logstash-output-elasticsearch-6.3.0-java spec/unit/http_client_builder_spec.rb
logstash-output-elasticsearch-6.2.6-java spec/unit/http_client_builder_spec.rb
logstash-output-elasticsearch-6.2.5-java spec/unit/http_client_builder_spec.rb
logstash-output-elasticsearch-6.2.4-java spec/unit/http_client_builder_spec.rb
logstash-output-elasticsearch-6.2.3-java spec/unit/http_client_builder_spec.rb
logstash-output-elasticsearch-6.2.2-java spec/unit/http_client_builder_spec.rb