Sha256: e3ce162bd60695708348e082f59e9ccc7896dc1ea5ef2217b0cca9da091af4f8

Contents?: true

Size: 1.36 KB

Versions: 194

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 query.moped" 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

194 entries across 194 versions & 1 rubygems

Version Path
appsignal-3.0.25-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.25 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.24-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.24 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.23-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.23 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.22-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.22 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.21-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.21 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.21.alpha.1-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.21.alpha.1 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.20-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.20 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.19-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.19 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.18-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.18 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.17-java spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
appsignal-3.0.17 spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb