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.55.2 lib/pact/hal/authorization_header_redactor.rb
pact-1.55.1 lib/pact/hal/authorization_header_redactor.rb
pact-1.55.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.54.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.53.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.52.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.51.1 lib/pact/hal/authorization_header_redactor.rb
pact-1.51.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.50.1 lib/pact/hal/authorization_header_redactor.rb
pact-1.50.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.49.3 lib/pact/hal/authorization_header_redactor.rb
pact-1.49.2 lib/pact/hal/authorization_header_redactor.rb
pact-1.49.1 lib/pact/hal/authorization_header_redactor.rb
pact-1.49.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.48.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.47.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.46.1 lib/pact/hal/authorization_header_redactor.rb
pact-1.46.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.45.0 lib/pact/hal/authorization_header_redactor.rb
pact-1.44.1 lib/pact/hal/authorization_header_redactor.rb