Sha256: c71e3f6857668a2d87854be5eaabfbc11abf7ea4de6b56db147f9d0606b63ea6

Contents?: true

Size: 1.36 KB

Versions: 120

Compression:

Stored size: 1.36 KB

Contents

describe Appsignal::EventFormatter::ElasticSearch::SearchFormatter do
  let(:klass)     { Appsignal::EventFormatter::ElasticSearch::SearchFormatter }
  let(:formatter) { klass.new }

  it "should register search.elasticsearch" do
    expect(
      Appsignal::EventFormatter.registered?("search.elasticsearch", klass)
    ).to be_truthy
  end

  describe "#format" do
    let(:payload) do
      {
        :name => "Search",
        :klass => "User",
        :search => { :index => "users", :type => "user", :q => "John Doe" }
      }
    end

    it "should return a payload with name and sanitized body" do
      expect(formatter.format(payload)).to eql([
        "Search: User",
        "{:index=>\"users\", :type=>\"user\", :q=>\"?\"}"
      ])
    end
  end

  describe "#sanitized_search" do
    let(:search) do
      {
        :index => "users",
        :type => "user",
        :q => "John Doe",
        :other => "Other"
      }
    end

    it "should sanitize non-allowlisted params" do
      expect(
        formatter.sanitized_search(search)
      ).to eql(:index => "users", :type => "user", :q => "?", :other => "?")
    end

    it "should return nil string when search is nil" do
      expect(formatter.sanitized_search(nil)).to be_nil
    end

    it "should return nil string when search is not a hash" do
      expect(formatter.sanitized_search([])).to be_nil
    end
  end
end

Version data entries

120 entries across 120 versions & 1 rubygems

Version Path
appsignal-4.0.6-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.6 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.5-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.5 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.4-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.4 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.3-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.3 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.2-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.2 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.1-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.1 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.0-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.0 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.13.1-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.13.1 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.13.1.alpha.1-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.13.1.alpha.1 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.0.beta.2-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-4.0.0.beta.2 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb