Sha256: f6ca90984005b3faf08afe49c8b1bde3863f8a2873081b3f3b3de29842a0aab3

Contents?: true

Size: 1.11 KB

Versions: 8

Compression:

Stored size: 1.11 KB

Contents

# encoding: utf-8

require "logstash/devutils/rspec/spec_helper"
require "logstash/filters/useragent"

describe LogStash::Filters::UserAgent do

  describe "defaults" do
    config <<-CONFIG
      filter {
        useragent {
          source => "message"
          target => "ua"
        }
      }
    CONFIG

    sample "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31" do
      insist { subject }.include?("ua")
      insist { subject["ua"]["name"] } == "Chrome"
      insist { subject["ua"]["os"] } == "Linux"
      insist { subject["ua"]["major"] } == "26"
      insist { subject["ua"]["minor"] } == "0"
    end
  end

  describe "Without target field" do
    config <<-CONFIG
      filter {
        useragent {
          source => "message"
        }
      }
    CONFIG

    sample "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31" do
      insist { subject["name"] } == "Chrome"
      insist { subject["os"] } == "Linux"
      insist { subject["major"] } == "26"
      insist { subject["minor"] } == "0"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
logstash-filter-useragent-1.0.1 spec/filters/useragent_spec.rb
logstash-filter-useragent-1.0.0 spec/filters/useragent_spec.rb
logstash-filter-useragent-0.1.8 spec/filters/useragent_spec.rb
logstash-filter-useragent-0.1.6 spec/filters/useragent_spec.rb
logstash-filter-useragent-0.1.5 spec/filters/useragent_spec.rb
logstash-filter-useragent-0.1.4 spec/filters/useragent_spec.rb
logstash-filter-useragent-0.1.3 spec/filters/useragent_spec.rb
logstash-filter-useragent-0.1.2 spec/filters/useragent_spec.rb