Sha256: 4b1aafd3ad52761a5d03f0fdedbbc83b47455b40b38fef26de259fc3e20cecf9

Contents?: true

Size: 652 Bytes

Versions: 14

Compression:

Stored size: 652 Bytes

Contents

require "delegate"

module Pact
  module Http
    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

14 entries across 14 versions & 2 rubygems

Version Path
pact-support-1.21.2 lib/pact/http/authorization_header_redactor.rb
pact-support-1.21.1 lib/pact/http/authorization_header_redactor.rb
pact-support-1.21.0 lib/pact/http/authorization_header_redactor.rb
pact-support-1.20.2 lib/pact/http/authorization_header_redactor.rb
pact-support-1.20.1 lib/pact/http/authorization_header_redactor.rb
pact-support-1.20.0 lib/pact/http/authorization_header_redactor.rb
pact-support-1.19.0 lib/pact/http/authorization_header_redactor.rb
pact-support-1.18.1 lib/pact/http/authorization_header_redactor.rb
pact-support-1.18.0 lib/pact/http/authorization_header_redactor.rb
hs-pact-support-1.17.1 lib/pact/http/authorization_header_redactor.rb
pact-support-1.17.0 lib/pact/http/authorization_header_redactor.rb
pact-support-1.16.10 lib/pact/http/authorization_header_redactor.rb
pact-support-1.16.9 lib/pact/http/authorization_header_redactor.rb
pact-support-1.16.8 lib/pact/http/authorization_header_redactor.rb