Sha256: 6af600e663f4579907e51e6028c549ca59e87ea5e76b8ee14de51f5f7286283d

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require "oauth/request_proxy/base"

module OAuth
  module RequestProxy
    # RequestProxy for Hashes to facilitate simpler signature creation.
    # Usage:
    #   request = OAuth::RequestProxy.proxy \
    #      "method" => "iq",
    #      "uri"    => [from, to] * "&",
    #      "parameters" => {
    #        "oauth_consumer_key"     => oauth_consumer_key,
    #        "oauth_token"            => oauth_token,
    #        "oauth_signature_method" => "HMAC-SHA1"
    #      }
    #
    #   signature = OAuth::Signature.sign \
    #     request,
    #     :consumer_secret => oauth_consumer_secret,
    #     :token_secret    => oauth_token_secret,
    class MockRequest < OAuth::RequestProxy::Base
      proxies ::Hash

      def parameters
        @request["parameters"]
      end

      def method
        @request["method"]
      end

      def normalized_uri
        super
      rescue StandardError
        # if this is a non-standard URI, it may not parse properly
        # in that case, assume that it's already been normalized
        uri
      end

      def uri
        @request["uri"]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
oauth-1.1.0 lib/oauth/request_proxy/mock_request.rb
oauth-1.0.1 lib/oauth/request_proxy/mock_request.rb
oauth-0.6.2 lib/oauth/request_proxy/mock_request.rb
oauth-1.0.0 lib/oauth/request_proxy/mock_request.rb
oauth-0.6.1 lib/oauth/request_proxy/mock_request.rb
oauth-0.6.0 lib/oauth/request_proxy/mock_request.rb