Sha256: fba80ff9b478ac7f5bcd9b0b76faec124c2565b7c19c34fb3605f1e5ccc2eb99

Contents?: true

Size: 1.89 KB

Versions: 4

Compression:

Stored size: 1.89 KB

Contents

require "logstash/devutils/rspec/spec_helper"
require "logstash/filters/google_appengine"
require "logstash/json"
require 'digest'

describe LogStash::Filters::GoogleAppengine do

  md5 = Digest::MD5.new

  config <<-CONFIG
        filter {
          google_appengine { }
         }
  CONFIG

  describe "should merge the request payload with the reuest lines data" do
    test_sample = LogStash::Json::load(File.open("spec/filters/appengine.logs.jsonl", "rb").read)
    sample (test_sample) do
      LATENCY_OF_REQUEST = 0.115752
      insist { subject.length } == 3

      insist { subject[0]["message"] }=="IdentityFilter logUserIdentity: [[meta]] <anonymous:true>\n"
      insist { subject[0]["id"] }== md5.hexdigest(subject[0]["requestId"] + "0")
      insist { subject[0]["time"] } == "2015-09-03T10:59:40.589Z"
      insist { subject[0]["position"] } == 0
      insist { subject[0]["@type"] } == nil
      insist { subject[0]["latencyS"] } == LATENCY_OF_REQUEST
      insist { subject[0]["pendingTimeS"] } == nil

      insist { subject[1]["message"] }=="HttpOnlyFilter getSession: add additional Set-Cookie with httpOnly-flag for JSESSIONID\n"
      insist { subject[1]["id"] } == md5.hexdigest(subject[1]["requestId"] + "1")
      insist { subject[1]["@type"] } == nil
      insist { subject[1]["time"] } =="2015-09-03T10:59:40.65Z"
      insist { subject[1]["position"] } == 1
      insist { subject[0]["pendingTimeS"] } == nil
    end
  end

  describe "should handle logs even when they have no lines" do
    test_sample = LogStash::Json.load(File.open("spec/filters/appengine.logs-without-lines.jsonl", "rb").read)
    sample (test_sample) do

      insist { subject["resource"] } == "/images/website/welcome/keyFeatures/objectives.jpg"
      insist { subject["id"] } == md5.hexdigest(subject["requestId"])
      insist { subject["time"] } == subject["endTime"]
      insist { subject["@type"] } == nil
    end
  end
end


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
logstash-filter-google_appengine-0.119.0 spec/filters/google_appengine_spec.rb
logstash-filter-google_appengine-0.118.0 spec/filters/google_appengine_spec.rb
logstash-filter-google_appengine-0.117.0 spec/filters/google_appengine_spec.rb
logstash-filter-google_appengine-0.116.0 spec/filters/google_appengine_spec.rb