Sha256: 1401125127d66417183716f7daac075fe7b16218de6477112a6ad05dd1493699

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8

require "logstash/devutils/rspec/spec_helper"
require "logstash/filters/checksum"
require 'openssl'

describe LogStash::Filters::Checksum do

  LogStash::Filters::Checksum::ALGORITHMS.each do |alg|
    describe "#{alg} checksum with single field" do
      config <<-CONFIG
        filter {
          checksum {
            algorithm => "#{alg}"
            keys => ["test"]
          }
        }
        CONFIG

      sample "test" => "foo bar" do
        insist { !subject.get("logstash_checksum").nil? }
        insist { subject.get("logstash_checksum") } == OpenSSL::Digest.hexdigest(alg, "foo bar")
      end
    end

    describe "#{alg} checksum with multiple keys" do
      config <<-CONFIG
        filter {
          checksum {
            algorithm => "#{alg}"
            keys => ["test1", "test2"]
          }
        }
        CONFIG

      sample "test1" => "foo", "test2" => "bar" do
        insist { !subject.get("logstash_checksum").nil? }
        insist { subject.get("logstash_checksum") } == OpenSSL::Digest.hexdigest(alg, "foobar")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
logstash-filter-checksum-3.0.4 spec/filters/checksum_spec.rb
logstash-filter-checksum-3.0.3 spec/filters/checksum_spec.rb
logstash-filter-checksum-3.0.2 spec/filters/checksum_spec.rb
logstash-filter-checksum-3.0.1 spec/filters/checksum_spec.rb
logstash-filter-checksum-3.0.0 spec/filters/checksum_spec.rb