Sha256: 5d8d6281dd0529cfab7b7f5a8f329b6f7a7e55ec78dfc98c595afe339f8ed121

Contents?: true

Size: 1.8 KB

Versions: 63

Compression:

Stored size: 1.8 KB

Contents

require 'pact_broker/webhooks/redact_logs'

module PactBroker
  module Webhooks
    describe RedactLogs do
      describe ".call" do
        let(:values) { [] }

        let(:string) do
          "Authorization: foo\nX-Thing: bar"
        end

        let(:x_auth_string) do
          "X-Authorization: bar foo\nX-Thing: bar"
        end

        let(:x_auth_token) do
          "X-Auth-Token: bar foo\nX-Thing: bar"
        end

        let(:x_authorization_token) do
          "X-Authorization-Token: bar foo\nX-Thing: bar"
        end

        let(:string_lower) do
          "authorization: foo\nX-Thing: bar"
        end

        it "hides the value of the Authorization header" do
          expect(RedactLogs.call(string, values)).to eq "Authorization: [REDACTED]\nX-Thing: bar"
        end

        it "hides the value of the X-Authorization header" do
          expect(RedactLogs.call(x_auth_string, values)).to eq "X-Authorization: [REDACTED]\nX-Thing: bar"
        end

        it "hides the value of the X-Auth-Token header" do
          expect(RedactLogs.call(x_auth_token, values)).to eq "X-Auth-Token: [REDACTED]\nX-Thing: bar"
        end

        it "hides the value of the X-Authorization-Token header" do
          expect(RedactLogs.call(x_authorization_token, values)).to eq "X-Authorization-Token: [REDACTED]\nX-Thing: bar"
        end

        it "hides the value of the authorization header" do
          expect(RedactLogs.call(string_lower, values)).to eq "authorization: [REDACTED]\nX-Thing: bar"
        end

        context "with values" do
          let(:values) { %w[foo bar] }
          let(:string) { "blahfoo\nbar wiffle" }

          it "hides the passed in values" do
            expect(RedactLogs.call(string, values)).to eq "blah********\n******** wiffle"
          end
        end
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
pact_broker-2.79.1 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.79.0 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.78.1 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.78.0 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.77.0 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.76.2 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.76.1 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.76.0 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.75.0 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.74.1 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.74.0 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.73.0 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.72.0 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.71.0 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.70.0 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.69.0 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.68.1 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.68.0 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.67.0 spec/lib/pact_broker/webhooks/redact_logs_spec.rb
pact_broker-2.66.0 spec/lib/pact_broker/webhooks/redact_logs_spec.rb