Sha256: fc810902a742e7423a0e70b61d5c18bc384923b9ecb99cd250c4421f70664605

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 KB

Contents

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

describe LogStash::Filters::Tld do
  describe "Set to TLD" do
    config <<-CONFIG
      filter {
        tld {
        }
      }
    CONFIG

#{
#       "message" => "google.com",
#      "@version" => "1",
#    "@timestamp" => "2015-01-22T17:33:19.669Z",
#          "host" => "homer",
#      "sequence" => 0,
#           "tld" => {
#              "tld" => "com",
#              "sld" => "google",
#              "trd" => nil,
#           "domain" => "google.com",
#        "subdomain" => nil
#    }


    sample("message" => "google.com") do
      insist { subject["tld"]["tld"] } == "com"
      insist { subject["tld"]["sld"] } == "google"
      insist { subject["tld"]["trd"] } == nil
      insist { subject["tld"]["domain"] } == "google.com"
      insist { subject["tld"]["subdomain"] } == nil
    end

    sample("message" => "google.co.uk") do
      insist { subject["tld"]["tld"] } == "co.uk"
      insist { subject["tld"]["sld"] } == "google"
      insist { subject["tld"]["trd"] } == nil
      insist { subject["tld"]["domain"] } == "google.co.uk"
      insist { subject["tld"]["subdomain"] } == nil
    end

    sample("message" => "www.google.com") do
      insist { subject["tld"]["tld"] } == "com"
      insist { subject["tld"]["sld"] } == "google"
      insist { subject["tld"]["trd"] } == "www"
      insist { subject["tld"]["domain"] } == "google.com"
      insist { subject["tld"]["subdomain"] } == "www.google.com"
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
logstash-filter-tld-2.0.4 spec/filters/tld_spec.rb
logstash-filter-tld-2.0.2 spec/filters/tld_spec.rb
logstash-filter-tld-2.0.1 spec/filters/tld_spec.rb
logstash-filter-tld-0.1.3 spec/filters/tld_spec.rb
logstash-filter-tld-0.1.2 spec/filters/tld_spec.rb
logstash-filter-tld-0.1.1 spec/filters/tld_spec.rb