Sha256: 0d0b11f4c678944515b8df8ba6bbf953f4dccffb6f7a2a5561cafeb499c5ca8d

Contents?: true

Size: 651 Bytes

Versions: 50

Compression:

Stored size: 651 Bytes

Contents

require 'delegate'

module Pact
  module Hal
    class AuthorizationHeaderRedactor < SimpleDelegator
      def puts(*args)
        __getobj__().puts(*redact_args(args))
      end

      def print(*args)
        __getobj__().puts(*redact_args(args))
      end

      def <<(*args)
        __getobj__().send(:<<, *redact_args(args))
      end

      private

      attr_reader :redactions

      def redact_args(args)
        args.collect{ | s| redact(s) }
      end

      def redact(string)
        return string unless string.is_a?(String)
        string.gsub(/Authorization: .*\\r\\n/, "Authorization: [redacted]\\r\\n")
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
pact-1.66.1 lib/pact/hal/authorization_header_redactor.rb
pact-1.66.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.65.3 lib/pact/hal/authorization_header_redactor.rb
pact-1.65.2 lib/pact/hal/authorization_header_redactor.rb
pact-1.65.1 lib/pact/hal/authorization_header_redactor.rb
pact-1.65.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.64.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.63.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.62.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.61.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.60.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.59.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.58.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.57.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.56.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.55.7 lib/pact/hal/authorization_header_redactor.rb
pact-1.55.6 lib/pact/hal/authorization_header_redactor.rb
pact-1.55.5 lib/pact/hal/authorization_header_redactor.rb
pact-1.55.4 lib/pact/hal/authorization_header_redactor.rb
pact-1.55.3 lib/pact/hal/authorization_header_redactor.rb