[DRE-commits] [ruby-oauth2] 01/06: Imported Upstream version 1.2.0

Praveen Arimbrathodiyil praveen at moszumanska.debian.org
Thu Jul 14 09:55:04 UTC 2016


This is an automated email from the git hooks/post-receive script.

praveen pushed a commit to branch master
in repository ruby-oauth2.

commit ac67bb4c0c5d8f8ae57d6de282e92caea0afd77a
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date:   Thu Jul 14 14:43:02 2016 +0530

    Imported Upstream version 1.2.0
---
 README.md                                       |   9 +-
 Rakefile                                        |  39 -----
 checksums.yaml.gz                               | Bin 270 -> 0 bytes
 lib/oauth2/access_token.rb                      |  20 ++-
 lib/oauth2/client.rb                            |  12 +-
 lib/oauth2/error.rb                             |  26 ++-
 lib/oauth2/mac_token.rb                         |  18 +-
 lib/oauth2/response.rb                          |  44 ++---
 lib/oauth2/strategy/assertion.rb                |  22 +--
 lib/oauth2/strategy/client_credentials.rb       |   6 +-
 lib/oauth2/strategy/implicit.rb                 |   2 +-
 lib/oauth2/strategy/password.rb                 |   2 +-
 lib/oauth2/version.rb                           |  66 ++++++--
 metadata.yml                                    | 179 --------------------
 oauth2.gemspec                                  |   7 +-
 spec/helper.rb                                  |  42 -----
 spec/oauth2/access_token_spec.rb                | 169 -------------------
 spec/oauth2/client_spec.rb                      | 215 ------------------------
 spec/oauth2/mac_token_spec.rb                   | 119 -------------
 spec/oauth2/response_spec.rb                    |  91 ----------
 spec/oauth2/strategy/assertion_spec.rb          |  56 ------
 spec/oauth2/strategy/auth_code_spec.rb          |  88 ----------
 spec/oauth2/strategy/base_spec.rb               |   7 -
 spec/oauth2/strategy/client_credentials_spec.rb |  81 ---------
 spec/oauth2/strategy/implicit_spec.rb           |  28 ---
 spec/oauth2/strategy/password_spec.rb           |  57 -------
 26 files changed, 146 insertions(+), 1259 deletions(-)

diff --git a/README.md b/README.md
index 90a1d93..7165a00 100644
--- a/README.md
+++ b/README.md
@@ -104,15 +104,14 @@ This library aims to support and is [tested against][travis] the following Ruby
 implementations:
 
 * Ruby 1.8.7
-* Ruby 1.9.2
 * Ruby 1.9.3
 * Ruby 2.0.0
-* Ruby 2.1.0
-* [JRuby][]
-* [Rubinius][]
+* Ruby 2.1
+* Ruby 2.2
+* Ruby 2.3
+* [JRuby 9K][]
 
 [jruby]: http://jruby.org/
-[rubinius]: http://rubini.us/
 
 If something doesn't work on one of these interpreters, it's a bug.
 
diff --git a/Rakefile b/Rakefile
deleted file mode 100644
index f105c62..0000000
--- a/Rakefile
+++ /dev/null
@@ -1,39 +0,0 @@
-require 'bundler'
-Bundler::GemHelper.install_tasks
-
-require 'rspec/core/rake_task'
-RSpec::Core::RakeTask.new(:spec)
-
-task :test => :spec
-
-namespace :doc do
-  require 'rdoc/task'
-  require File.expand_path('../lib/oauth2/version', __FILE__)
-  RDoc::Task.new do |rdoc|
-    rdoc.rdoc_dir = 'rdoc'
-    rdoc.title = "oauth2 #{OAuth2::Version}"
-    rdoc.main = 'README.md'
-    rdoc.rdoc_files.include('README.md', 'LICENSE.md', 'lib/**/*.rb')
-  end
-end
-
-begin
-  require 'rubocop/rake_task'
-  RuboCop::RakeTask.new
-rescue LoadError
-  task :rubocop do
-    $stderr.puts 'RuboCop is disabled'
-  end
-end
-
-require 'yardstick/rake/measurement'
-Yardstick::Rake::Measurement.new do |measurement|
-  measurement.output = 'measurement/report.txt'
-end
-
-require 'yardstick/rake/verify'
-Yardstick::Rake::Verify.new do |verify|
-  verify.threshold = 58.8
-end
-
-task :default => [:spec, :rubocop, :verify_measurements]
diff --git a/checksums.yaml.gz b/checksums.yaml.gz
deleted file mode 100644
index fbcbba5..0000000
Binary files a/checksums.yaml.gz and /dev/null differ
diff --git a/lib/oauth2/access_token.rb b/lib/oauth2/access_token.rb
index a5ef250..077cda6 100644
--- a/lib/oauth2/access_token.rb
+++ b/lib/oauth2/access_token.rb
@@ -10,6 +10,7 @@ module OAuth2
       # @param [Hash] a hash of AccessToken property values
       # @return [AccessToken] the initalized AccessToken
       def from_hash(client, hash)
+        hash = hash.dup
         new(client, hash.delete('access_token') || hash.delete(:access_token), hash)
       end
 
@@ -36,9 +37,10 @@ module OAuth2
     # @option opts [String] :header_format ('Bearer %s') the string format to use for the Authorization header
     # @option opts [String] :param_name ('access_token') the parameter name to use for transmission of the
     #    Access Token value in :body or :query transmission mode
-    def initialize(client, token, opts = {})
+    def initialize(client, token, opts = {}) # rubocop:disable Metrics/AbcSize
       @client = client
       @token = token.to_s
+      opts = opts.dup
       [:refresh_token, :expires_in, :expires_at].each do |arg|
         instance_variable_set("@#{arg}", opts.delete(arg) || opts.delete(arg.to_s))
       end
@@ -63,7 +65,7 @@ module OAuth2
     #
     # @return [Boolean]
     def expires?
-      !!@expires_at # rubocop:disable DoubleNegation
+      !!@expires_at
     end
 
     # Whether or not the token is expired
@@ -78,11 +80,11 @@ module OAuth2
     # @return [AccessToken] a new AccessToken
     # @note options should be carried over to the new AccessToken
     def refresh!(params = {})
-      fail('A refresh_token is not available') unless refresh_token
-      params.merge!(:client_id      => @client.id,
-                    :client_secret  => @client.secret,
-                    :grant_type     => 'refresh_token',
-                    :refresh_token  => refresh_token)
+      raise('A refresh_token is not available') unless refresh_token
+      params[:client_id] = @client.id
+      params[:client_secret] = @client.secret
+      params[:grant_type] = 'refresh_token'
+      params[:refresh_token] = refresh_token
       new_token = @client.get_token(params)
       new_token.options = options
       new_token.refresh_token = refresh_token unless new_token.refresh_token
@@ -149,7 +151,7 @@ module OAuth2
 
   private
 
-    def token=(opts) # rubocop:disable MethodLength
+    def token=(opts) # rubocop:disable MethodLength, Metrics/AbcSize
       case options[:mode]
       when :header
         opts[:headers] ||= {}
@@ -166,7 +168,7 @@ module OAuth2
         end
         # @todo support for multi-part (file uploads)
       else
-        fail("invalid :mode option of #{options[:mode]}")
+        raise("invalid :mode option of #{options[:mode]}")
       end
     end
   end
diff --git a/lib/oauth2/client.rb b/lib/oauth2/client.rb
index 4c5c725..cb1b564 100644
--- a/lib/oauth2/client.rb
+++ b/lib/oauth2/client.rb
@@ -85,7 +85,7 @@ module OAuth2
     #   code response for this request.  Will default to client option
     # @option opts [Symbol] :parse @see Response::initialize
     # @yield [req] The Faraday request
-    def request(verb, url, opts = {}) # rubocop:disable CyclomaticComplexity, MethodLength
+    def request(verb, url, opts = {}) # rubocop:disable CyclomaticComplexity, MethodLength, Metrics/AbcSize
       connection.response :logger, ::Logger.new($stdout) if ENV['OAUTH_DEBUG'] == 'true'
 
       url = connection.build_url(url, opts[:params]).to_s
@@ -110,12 +110,12 @@ module OAuth2
         response
       when 400..599
         error = Error.new(response)
-        fail(error) if opts.fetch(:raise_errors, options[:raise_errors])
+        raise(error) if opts.fetch(:raise_errors, options[:raise_errors])
         response.error = error
         response
       else
         error = Error.new(response)
-        fail(error, "Unhandled status code value of #{response.status}")
+        raise(error, "Unhandled status code value of #{response.status}")
       end
     end
 
@@ -125,19 +125,19 @@ module OAuth2
     # @param [Hash] access token options, to pass to the AccessToken object
     # @param [Class] class of access token for easier subclassing OAuth2::AccessToken
     # @return [AccessToken] the initalized AccessToken
-    def get_token(params, access_token_opts = {}, access_token_class = AccessToken)
+    def get_token(params, access_token_opts = {}, access_token_class = AccessToken) # rubocop:disable Metrics/AbcSize
       opts = {:raise_errors => options[:raise_errors], :parse => params.delete(:parse)}
       if options[:token_method] == :post
         headers = params.delete(:headers)
         opts[:body] = params
-        opts[:headers] =  {'Content-Type' => 'application/x-www-form-urlencoded'}
+        opts[:headers] = {'Content-Type' => 'application/x-www-form-urlencoded'}
         opts[:headers].merge!(headers) if headers
       else
         opts[:params] = params
       end
       response = request(options[:token_method], token_url, opts)
       error = Error.new(response)
-      fail(error) if options[:raise_errors] && !(response.parsed.is_a?(Hash) && response.parsed['access_token'])
+      raise(error) if options[:raise_errors] && !(response.parsed.is_a?(Hash) && response.parsed['access_token'])
       access_token_class.from_hash(self, response.parsed.merge(access_token_opts))
     end
 
diff --git a/lib/oauth2/error.rb b/lib/oauth2/error.rb
index ddb9b7c..c49a553 100644
--- a/lib/oauth2/error.rb
+++ b/lib/oauth2/error.rb
@@ -8,17 +8,33 @@ module OAuth2
       response.error = self
       @response = response
 
-      message = []
-
       if response.parsed.is_a?(Hash)
         @code = response.parsed['error']
         @description = response.parsed['error_description']
-        message << "#{@code}: #{@description}"
+        error_description = "#{@code}: #{@description}"
       end
 
-      message << response.body
+      super(error_message(response.body, :error_description => error_description))
+    end
+
+    # Makes a error message
+    # @param [String] response_body response body of request
+    # @param [String] opts :error_description error description to show first line
+    def error_message(response_body, opts = {})
+      message = []
+
+      opts[:error_description] && message << opts[:error_description]
+
+      error_message = if opts[:error_description] && opts[:error_description].respond_to?(:encoding)
+                        script_encoding = opts[:error_description].encoding
+                        response_body.encode(script_encoding)
+                      else
+                        response_body
+                      end
+
+      message << error_message
 
-      super(message.join("\n"))
+      message.join("\n")
     end
   end
 end
diff --git a/lib/oauth2/mac_token.rb b/lib/oauth2/mac_token.rb
index 1d9aae6..8e206c7 100644
--- a/lib/oauth2/mac_token.rb
+++ b/lib/oauth2/mac_token.rb
@@ -12,11 +12,7 @@ module OAuth2
     # @param [Hash] opts the options to create the Access Token with
     # @see MACToken#initialize
     def self.from_access_token(token, secret, options = {})
-      new(token.client, token.token, secret, token.params.merge(
-        :refresh_token => token.refresh_token,
-        :expires_in => token.expires_in,
-        :expires_at => token.expires_at
-      ).merge(options))
+      new(token.client, token.token, secret, token.params.merge(:refresh_token => token.refresh_token, :expires_in => token.expires_in, :expires_at => token.expires_at).merge(options))
     end
 
     attr_reader :secret, :algorithm
@@ -48,7 +44,7 @@ module OAuth2
       url = client.connection.build_url(path, opts[:params]).to_s
 
       opts[:headers] ||= {}
-      opts[:headers].merge!('Authorization' => header(verb, url))
+      opts[:headers]['Authorization'] = header(verb, url)
 
       @client.request(verb, path, opts, &block)
     end
@@ -68,7 +64,7 @@ module OAuth2
 
       uri = URI.parse(url)
 
-      fail(ArgumentError, "could not parse \"#{url}\" into URI") unless uri.is_a?(URI::HTTP)
+      raise(ArgumentError, "could not parse \"#{url}\" into URI") unless uri.is_a?(URI::HTTP)
 
       mac = signature(timestamp, nonce, verb, uri)
 
@@ -99,14 +95,16 @@ module OAuth2
     #
     # @param [String] alg the algorithm to use (one of 'hmac-sha-1', 'hmac-sha-256')
     def algorithm=(alg)
-      @algorithm = case alg.to_s
+      @algorithm = begin
+        case alg.to_s
         when 'hmac-sha-1'
           OpenSSL::Digest::SHA1.new
         when 'hmac-sha-256'
           OpenSSL::Digest::SHA256.new
         else
-          fail(ArgumentError, 'Unsupported algorithm')
+          raise(ArgumentError, 'Unsupported algorithm')
         end
+      end
     end
 
   private
@@ -118,7 +116,7 @@ module OAuth2
 
     # Base64.strict_encode64 is not available on Ruby 1.8.7
     def strict_encode64(str)
-      Base64.encode64(str).gsub("\n", '')
+      Base64.encode64(str).delete("\n")
     end
   end
 end
diff --git a/lib/oauth2/response.rb b/lib/oauth2/response.rb
index 5cdd86a..9547779 100644
--- a/lib/oauth2/response.rb
+++ b/lib/oauth2/response.rb
@@ -8,6 +8,22 @@ module OAuth2
     attr_reader :response
     attr_accessor :error, :options
 
+    # Procs that, when called, will parse a response body according
+    # to the specified format.
+    @@parsers = {
+      :json  => lambda { |body| MultiJson.load(body) rescue body }, # rubocop:disable RescueModifier
+      :query => lambda { |body| Rack::Utils.parse_query(body) },
+      :text  => lambda { |body| body },
+    }
+
+    # Content type assignments for various potential HTTP content types.
+    @@content_types = {
+      'application/json' => :json,
+      'text/javascript' => :json,
+      'application/x-www-form-urlencoded' => :query,
+      'text/plain' => :text,
+    }
+
     # Adds a new content type parser.
     #
     # @param [Symbol] key A descriptive symbol key such as :json or :query.
@@ -15,9 +31,9 @@ module OAuth2
     # @yield [String] A block returning parsed content.
     def self.register_parser(key, mime_types, &block)
       key = key.to_sym
-      PARSERS[key] = block
+      @@parsers[key] = block
       Array(mime_types).each do |mime_type|
-        CONTENT_TYPES[mime_type] = key
+        @@content_types[mime_type] = key
       end
     end
 
@@ -47,28 +63,12 @@ module OAuth2
       response.body || ''
     end
 
-    # Procs that, when called, will parse a response body according
-    # to the specified format.
-    PARSERS = {
-      :json  => lambda { |body| MultiJson.load(body) rescue body }, # rubocop:disable RescueModifier
-      :query => lambda { |body| Rack::Utils.parse_query(body) },
-      :text  => lambda { |body| body }
-    }
-
-    # Content type assignments for various potential HTTP content types.
-    CONTENT_TYPES = {
-      'application/json' => :json,
-      'text/javascript' => :json,
-      'application/x-www-form-urlencoded' => :query,
-      'text/plain' => :text
-    }
-
     # The parsed response body.
     #   Will attempt to parse application/x-www-form-urlencoded and
     #   application/json Content-Type response bodies
     def parsed
-      return nil unless PARSERS.key?(parser)
-      @parsed ||= PARSERS[parser].call(body)
+      return nil unless @@parsers.key?(parser)
+      @parsed ||= @@parsers[parser].call(body)
     end
 
     # Attempts to determine the content type of the response.
@@ -78,8 +78,8 @@ module OAuth2
 
     # Determines the parser that will be used to supply the content of #parsed
     def parser
-      return options[:parse].to_sym if PARSERS.key?(options[:parse])
-      CONTENT_TYPES[content_type]
+      return options[:parse].to_sym if @@parsers.key?(options[:parse])
+      @@content_types[content_type]
     end
   end
 end
diff --git a/lib/oauth2/strategy/assertion.rb b/lib/oauth2/strategy/assertion.rb
index 4275963..5f51ebe 100644
--- a/lib/oauth2/strategy/assertion.rb
+++ b/lib/oauth2/strategy/assertion.rb
@@ -25,7 +25,7 @@ module OAuth2
       #
       # @raise [NotImplementedError]
       def authorize_url
-        fail(NotImplementedError, 'The authorization endpoint is not used in this strategy')
+        raise(NotImplementedError, 'The authorization endpoint is not used in this strategy')
       end
 
       # Retrieve an access token given the specified client.
@@ -49,19 +49,21 @@ module OAuth2
 
       def build_request(params)
         assertion = build_assertion(params)
-        {:grant_type     => 'assertion',
-         :assertion_type => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
-         :assertion      => assertion,
-         :scope          => params[:scope]
+        {
+          :grant_type     => 'assertion',
+          :assertion_type => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
+          :assertion      => assertion,
+          :scope          => params[:scope],
         }.merge(client_params)
       end
 
       def build_assertion(params)
-        claims = {:iss => params[:iss],
-                  :aud => params[:aud],
-                  :prn => params[:prn],
-                  :exp => params[:exp]
-                 }
+        claims = {
+          :iss => params[:iss],
+          :aud => params[:aud],
+          :prn => params[:prn],
+          :exp => params[:exp],
+        }
         if params[:hmac_secret]
           JWT.encode(claims, params[:hmac_secret], 'HS256')
         elsif params[:private_key]
diff --git a/lib/oauth2/strategy/client_credentials.rb b/lib/oauth2/strategy/client_credentials.rb
index 4ceb5e5..e4a5a8c 100644
--- a/lib/oauth2/strategy/client_credentials.rb
+++ b/lib/oauth2/strategy/client_credentials.rb
@@ -10,7 +10,7 @@ module OAuth2
       #
       # @raise [NotImplementedError]
       def authorize_url
-        fail(NotImplementedError, 'The authorization endpoint is not used in this strategy')
+        raise(NotImplementedError, 'The authorization endpoint is not used in this strategy')
       end
 
       # Retrieve an access token given the specified client.
@@ -19,7 +19,7 @@ module OAuth2
       # @param [Hash] opts options
       def get_token(params = {}, opts = {})
         request_body = opts.delete('auth_scheme') == 'request_body'
-        params.merge!('grant_type' => 'client_credentials')
+        params['grant_type'] = 'client_credentials'
         params.merge!(request_body ? client_params : {:headers => {'Authorization' => authorization(client_params['client_id'], client_params['client_secret'])}})
         @client.get_token(params, opts.merge('refresh_token' => nil))
       end
@@ -29,7 +29,7 @@ module OAuth2
       # @param [String] The client ID
       # @param [String] the client secret
       def authorization(client_id, client_secret)
-        'Basic ' + Base64.encode64(client_id + ':' + client_secret).gsub("\n", '')
+        'Basic ' + Base64.encode64(client_id + ':' + client_secret).delete("\n")
       end
     end
   end
diff --git a/lib/oauth2/strategy/implicit.rb b/lib/oauth2/strategy/implicit.rb
index 25c167e..6ab505d 100644
--- a/lib/oauth2/strategy/implicit.rb
+++ b/lib/oauth2/strategy/implicit.rb
@@ -22,7 +22,7 @@ module OAuth2
       #
       # @raise [NotImplementedError]
       def get_token(*)
-        fail(NotImplementedError, 'The token is accessed differently in this strategy')
+        raise(NotImplementedError, 'The token is accessed differently in this strategy')
       end
     end
   end
diff --git a/lib/oauth2/strategy/password.rb b/lib/oauth2/strategy/password.rb
index 4853e66..99f61e9 100644
--- a/lib/oauth2/strategy/password.rb
+++ b/lib/oauth2/strategy/password.rb
@@ -8,7 +8,7 @@ module OAuth2
       #
       # @raise [NotImplementedError]
       def authorize_url
-        fail(NotImplementedError, 'The authorization endpoint is not used in this strategy')
+        raise(NotImplementedError, 'The authorization endpoint is not used in this strategy')
       end
 
       # Retrieve an access token given the specified End User username and password.
diff --git a/lib/oauth2/version.rb b/lib/oauth2/version.rb
index c3a428b..acc59c0 100644
--- a/lib/oauth2/version.rb
+++ b/lib/oauth2/version.rb
@@ -1,15 +1,59 @@
 module OAuth2
-  class Version
-    MAJOR = 1
-    MINOR = 0
-    PATCH = 0
-    PRE = nil
-
-    class << self
-      # @return [String]
-      def to_s
-        [MAJOR, MINOR, PATCH, PRE].compact.join('.')
-      end
+  module Version
+  module_function
+
+    # The major version
+    #
+    # @return [Integer]
+    def major
+      1
+    end
+
+    # The minor version
+    #
+    # @return [Integer]
+    def minor
+      2
+    end
+
+    # The patch version
+    #
+    # @return [Integer]
+    def patch
+      0
+    end
+
+    # The pre-release version, if any
+    #
+    # @return [Integer, NilClass]
+    def pre
+      nil
+    end
+
+    # The version number as a hash
+    #
+    # @return [Hash]
+    def to_h
+      {
+        :major => major,
+        :minor => minor,
+        :patch => patch,
+        :pre => pre,
+      }
+    end
+
+    # The version number as an array
+    #
+    # @return [Array]
+    def to_a
+      [major, minor, patch, pre].compact
+    end
+
+    # The version number as a string
+    #
+    # @return [String]
+    def to_s
+      to_a.join('.')
     end
   end
 end
diff --git a/metadata.yml b/metadata.yml
deleted file mode 100644
index 3f2fefd..0000000
--- a/metadata.yml
+++ /dev/null
@@ -1,179 +0,0 @@
---- !ruby/object:Gem::Specification
-name: oauth2
-version: !ruby/object:Gem::Version
-  version: 1.0.0
-platform: ruby
-authors:
-- Michael Bleigh
-- Erik Michaels-Ober
-autorequire: 
-bindir: bin
-cert_chain: []
-date: 2014-07-09 00:00:00.000000000 Z
-dependencies:
-- !ruby/object:Gem::Dependency
-  name: faraday
-  requirement: !ruby/object:Gem::Requirement
-    requirements:
-    - - ">="
-      - !ruby/object:Gem::Version
-        version: '0.8'
-    - - "<"
-      - !ruby/object:Gem::Version
-        version: '0.10'
-  type: :runtime
-  prerelease: false
-  version_requirements: !ruby/object:Gem::Requirement
-    requirements:
-    - - ">="
-      - !ruby/object:Gem::Version
-        version: '0.8'
-    - - "<"
-      - !ruby/object:Gem::Version
-        version: '0.10'
-- !ruby/object:Gem::Dependency
-  name: jwt
-  requirement: !ruby/object:Gem::Requirement
-    requirements:
-    - - "~>"
-      - !ruby/object:Gem::Version
-        version: '1.0'
-  type: :runtime
-  prerelease: false
-  version_requirements: !ruby/object:Gem::Requirement
-    requirements:
-    - - "~>"
-      - !ruby/object:Gem::Version
-        version: '1.0'
-- !ruby/object:Gem::Dependency
-  name: multi_json
-  requirement: !ruby/object:Gem::Requirement
-    requirements:
-    - - "~>"
-      - !ruby/object:Gem::Version
-        version: '1.3'
-  type: :runtime
-  prerelease: false
-  version_requirements: !ruby/object:Gem::Requirement
-    requirements:
-    - - "~>"
-      - !ruby/object:Gem::Version
-        version: '1.3'
-- !ruby/object:Gem::Dependency
-  name: multi_xml
-  requirement: !ruby/object:Gem::Requirement
-    requirements:
-    - - "~>"
-      - !ruby/object:Gem::Version
-        version: '0.5'
-  type: :runtime
-  prerelease: false
-  version_requirements: !ruby/object:Gem::Requirement
-    requirements:
-    - - "~>"
-      - !ruby/object:Gem::Version
-        version: '0.5'
-- !ruby/object:Gem::Dependency
-  name: rack
-  requirement: !ruby/object:Gem::Requirement
-    requirements:
-    - - "~>"
-      - !ruby/object:Gem::Version
-        version: '1.2'
-  type: :runtime
-  prerelease: false
-  version_requirements: !ruby/object:Gem::Requirement
-    requirements:
-    - - "~>"
-      - !ruby/object:Gem::Version
-        version: '1.2'
-- !ruby/object:Gem::Dependency
-  name: bundler
-  requirement: !ruby/object:Gem::Requirement
-    requirements:
-    - - "~>"
-      - !ruby/object:Gem::Version
-        version: '1.0'
-  type: :development
-  prerelease: false
-  version_requirements: !ruby/object:Gem::Requirement
-    requirements:
-    - - "~>"
-      - !ruby/object:Gem::Version
-        version: '1.0'
-description: A Ruby wrapper for the OAuth 2.0 protocol built with a similar style
-  to the original OAuth spec.
-email:
-- michael at intridea.com
-- sferik at gmail.com
-executables: []
-extensions: []
-extra_rdoc_files: []
-files:
-- ".document"
-- CONTRIBUTING.md
-- LICENSE.md
-- README.md
-- Rakefile
-- lib/oauth2.rb
-- lib/oauth2/access_token.rb
-- lib/oauth2/client.rb
-- lib/oauth2/error.rb
-- lib/oauth2/mac_token.rb
-- lib/oauth2/response.rb
-- lib/oauth2/strategy/assertion.rb
-- lib/oauth2/strategy/auth_code.rb
-- lib/oauth2/strategy/base.rb
-- lib/oauth2/strategy/client_credentials.rb
-- lib/oauth2/strategy/implicit.rb
-- lib/oauth2/strategy/password.rb
-- lib/oauth2/version.rb
-- oauth2.gemspec
-- spec/helper.rb
-- spec/oauth2/access_token_spec.rb
-- spec/oauth2/client_spec.rb
-- spec/oauth2/mac_token_spec.rb
-- spec/oauth2/response_spec.rb
-- spec/oauth2/strategy/assertion_spec.rb
-- spec/oauth2/strategy/auth_code_spec.rb
-- spec/oauth2/strategy/base_spec.rb
-- spec/oauth2/strategy/client_credentials_spec.rb
-- spec/oauth2/strategy/implicit_spec.rb
-- spec/oauth2/strategy/password_spec.rb
-homepage: http://github.com/intridea/oauth2
-licenses:
-- MIT
-metadata: {}
-post_install_message: 
-rdoc_options: []
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
-  requirements:
-  - - ">="
-    - !ruby/object:Gem::Version
-      version: '0'
-required_rubygems_version: !ruby/object:Gem::Requirement
-  requirements:
-  - - ">="
-    - !ruby/object:Gem::Version
-      version: 1.3.5
-requirements: []
-rubyforge_project: 
-rubygems_version: 2.2.2
-signing_key: 
-specification_version: 4
-summary: A Ruby wrapper for the OAuth 2.0 protocol.
-test_files:
-- spec/helper.rb
-- spec/oauth2/access_token_spec.rb
-- spec/oauth2/client_spec.rb
-- spec/oauth2/mac_token_spec.rb
-- spec/oauth2/response_spec.rb
-- spec/oauth2/strategy/assertion_spec.rb
-- spec/oauth2/strategy/auth_code_spec.rb
-- spec/oauth2/strategy/base_spec.rb
-- spec/oauth2/strategy/client_credentials_spec.rb
-- spec/oauth2/strategy/implicit_spec.rb
-- spec/oauth2/strategy/password_spec.rb
-has_rdoc: 
diff --git a/oauth2.gemspec b/oauth2.gemspec
index 3a91001..efb8f68 100644
--- a/oauth2.gemspec
+++ b/oauth2.gemspec
@@ -8,20 +8,17 @@ Gem::Specification.new do |spec|
   spec.add_dependency 'jwt', '~> 1.0'
   spec.add_dependency 'multi_json', '~> 1.3'
   spec.add_dependency 'multi_xml', '~> 0.5'
-  spec.add_dependency 'rack', '~> 1.2'
+  spec.add_dependency 'rack', ['>= 1.2', '< 3']
   spec.add_development_dependency 'bundler', '~> 1.0'
   spec.authors       = ['Michael Bleigh', 'Erik Michaels-Ober']
   spec.description   = 'A Ruby wrapper for the OAuth 2.0 protocol built with a similar style to the original OAuth spec.'
   spec.email         = ['michael at intridea.com', 'sferik at gmail.com']
-  spec.files         = %w(.document CONTRIBUTING.md LICENSE.md README.md Rakefile oauth2.gemspec)
-  spec.files        += Dir.glob('lib/**/*.rb')
-  spec.files        += Dir.glob('spec/**/*')
+  spec.files         = %w(.document CONTRIBUTING.md LICENSE.md README.md oauth2.gemspec) + Dir['lib/**/*.rb']
   spec.homepage      = 'http://github.com/intridea/oauth2'
   spec.licenses      = %w(MIT)
   spec.name          = 'oauth2'
   spec.require_paths = %w(lib)
   spec.required_rubygems_version = '>= 1.3.5'
   spec.summary       = 'A Ruby wrapper for the OAuth 2.0 protocol.'
-  spec.test_files    = Dir.glob('spec/**/*')
   spec.version       = OAuth2::Version
 end
diff --git a/spec/helper.rb b/spec/helper.rb
deleted file mode 100644
index 0c13511..0000000
--- a/spec/helper.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require 'simplecov'
-require 'coveralls'
-
-SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
-  SimpleCov::Formatter::HTMLFormatter,
-  Coveralls::SimpleCov::Formatter
-]
-
-SimpleCov.start do
-  add_filter '/spec/'
-  minimum_coverage(95.33)
-end
-
-require 'oauth2'
-require 'addressable/uri'
-require 'rspec'
-
-RSpec.configure do |config|
-  config.expect_with :rspec do |c|
-    c.syntax = :expect
-  end
-end
-
-Faraday.default_adapter = :test
-
-RSpec.configure do |conf|
-  include OAuth2
-end
-
-def capture_output(&block)
-  begin
-    old_stdout = $stdout
-    $stdout = StringIO.new
-    block.call
-    result = $stdout.string
-  ensure
-    $stdout = old_stdout
-  end
-  result
-end
-
-VERBS = [:get, :post, :put, :delete]
diff --git a/spec/oauth2/access_token_spec.rb b/spec/oauth2/access_token_spec.rb
deleted file mode 100644
index 27793fc..0000000
--- a/spec/oauth2/access_token_spec.rb
+++ /dev/null
@@ -1,169 +0,0 @@
-require 'helper'
-
-describe AccessToken do
-  let(:token) { 'monkey' }
-  let(:refresh_body) { MultiJson.encode(:access_token => 'refreshed_foo', :expires_in => 600, :refresh_token => 'refresh_bar') }
-  let(:client) do
-    Client.new('abc', 'def', :site => 'https://api.example.com') do |builder|
-      builder.request :url_encoded
-      builder.adapter :test do |stub|
-        VERBS.each do |verb|
-          stub.send(verb, '/token/header') { |env| [200, {}, env[:request_headers]['Authorization']] }
-          stub.send(verb, "/token/query?access_token=#{token}") { |env| [200, {}, Addressable::URI.parse(env[:url]).query_values['access_token']] }
-          stub.send(verb, '/token/body') { |env| [200, {}, env[:body]] }
-        end
-        stub.post('/oauth/token') { |env| [200, {'Content-Type' => 'application/json'}, refresh_body] }
-      end
-    end
-  end
-
-  subject { AccessToken.new(client, token) }
-
-  describe '#initialize' do
-    it 'assigns client and token' do
-      expect(subject.client).to eq(client)
-      expect(subject.token).to eq(token)
-    end
-
-    it 'assigns extra params' do
-      target = AccessToken.new(client, token, 'foo' => 'bar')
-      expect(target.params).to include('foo')
-      expect(target.params['foo']).to eq('bar')
-    end
-
-    def assert_initialized_token(target)
-      expect(target.token).to eq(token)
-      expect(target).to be_expires
-      expect(target.params.keys).to include('foo')
-      expect(target.params['foo']).to eq('bar')
-    end
-
-    it 'initializes with a Hash' do
-      hash = {:access_token => token, :expires_at => Time.now.to_i + 200, 'foo' => 'bar'}
-      target = AccessToken.from_hash(client, hash)
-      assert_initialized_token(target)
-    end
-
-    it 'initalizes with a form-urlencoded key/value string' do
-      kvform = "access_token=#{token}&expires_at=#{Time.now.to_i + 200}&foo=bar"
-      target = AccessToken.from_kvform(client, kvform)
-      assert_initialized_token(target)
-    end
-
-    it 'sets options' do
-      target = AccessToken.new(client, token, :param_name => 'foo', :header_format => 'Bearer %', :mode => :body)
-      expect(target.options[:param_name]).to eq('foo')
-      expect(target.options[:header_format]).to eq('Bearer %')
-      expect(target.options[:mode]).to eq(:body)
-    end
-
-    it 'initializes with a string expires_at' do
-      hash = {:access_token => token, :expires_at => '1361396829', 'foo' => 'bar'}
-      target = AccessToken.from_hash(client, hash)
-      assert_initialized_token(target)
-      expect(target.expires_at).to be_a(Integer)
-    end
-  end
-
-  describe '#request' do
-    context ':mode => :header' do
-      before do
-        subject.options[:mode] = :header
-      end
-
-      VERBS.each do |verb|
-        it "sends the token in the Authorization header for a #{verb.to_s.upcase} request" do
-          expect(subject.post('/token/header').body).to include(token)
-        end
-      end
-    end
-
-    context ':mode => :query' do
-      before do
-        subject.options[:mode] = :query
-      end
-
-      VERBS.each do |verb|
-        it "sends the token in the Authorization header for a #{verb.to_s.upcase} request" do
-          expect(subject.post('/token/query').body).to eq(token)
-        end
-      end
-    end
-
-    context ':mode => :body' do
-      before do
-        subject.options[:mode] = :body
-      end
-
-      VERBS.each do |verb|
-        it "sends the token in the Authorization header for a #{verb.to_s.upcase} request" do
-          expect(subject.post('/token/body').body.split('=').last).to eq(token)
-        end
-      end
-    end
-  end
-
-  describe '#expires?' do
-    it 'is false if there is no expires_at' do
-      expect(AccessToken.new(client, token)).not_to be_expires
-    end
-
-    it 'is true if there is an expires_in' do
-      expect(AccessToken.new(client, token, :refresh_token => 'abaca', :expires_in => 600)).to be_expires
-    end
-
-    it 'is true if there is an expires_at' do
-      expect(AccessToken.new(client, token, :refresh_token => 'abaca', :expires_in => Time.now.getutc.to_i + 600)).to be_expires
-    end
-  end
-
-  describe '#expired?' do
-    it 'is false if there is no expires_in or expires_at' do
-      expect(AccessToken.new(client, token)).not_to be_expired
-    end
-
-    it 'is false if expires_in is in the future' do
-      expect(AccessToken.new(client, token, :refresh_token => 'abaca', :expires_in => 10_800)).not_to be_expired
-    end
-
-    it 'is true if expires_at is in the past' do
-      access = AccessToken.new(client, token, :refresh_token => 'abaca', :expires_in => 600)
-      @now = Time.now + 10_800
-      allow(Time).to receive(:now).and_return(@now)
-      expect(access).to be_expired
-    end
-
-  end
-
-  describe '#refresh!' do
-    let(:access) do
-      AccessToken.new(client, token, :refresh_token  => 'abaca',
-                                     :expires_in     => 600,
-                                     :param_name     => 'o_param')
-    end
-
-    it 'returns a refresh token with appropriate values carried over' do
-      refreshed = access.refresh!
-      expect(access.client).to eq(refreshed.client)
-      expect(access.options[:param_name]).to eq(refreshed.options[:param_name])
-    end
-
-    context 'with a nil refresh_token in the response' do
-      let(:refresh_body) { MultiJson.encode(:access_token => 'refreshed_foo', :expires_in => 600, :refresh_token => nil) }
-
-      it 'copies the refresh_token from the original token' do
-        refreshed = access.refresh!
-
-        expect(refreshed.refresh_token).to eq(access.refresh_token)
-      end
-    end
-  end
-
-  describe '#to_hash' do
-    it 'return a hash equals to the hash used to initialize access token' do
-      hash = {:access_token => token, :refresh_token => 'foobar', :expires_at => Time.now.to_i + 200, 'foo' => 'bar'}
-      access_token = AccessToken.from_hash(client, hash.clone)
-      expect(access_token.to_hash).to eq(hash)
-    end
-  end
-end
diff --git a/spec/oauth2/client_spec.rb b/spec/oauth2/client_spec.rb
deleted file mode 100644
index 5a4c100..0000000
--- a/spec/oauth2/client_spec.rb
+++ /dev/null
@@ -1,215 +0,0 @@
-require 'helper'
-
-describe OAuth2::Client do
-  let!(:error_value) { 'invalid_token' }
-  let!(:error_description_value) { 'bad bad token' }
-
-  subject do
-    OAuth2::Client.new('abc', 'def', :site => 'https://api.example.com') do |builder|
-      builder.adapter :test do |stub|
-        stub.get('/success')      { |env| [200, {'Content-Type' => 'text/awesome'}, 'yay'] }
-        stub.get('/reflect')      { |env| [200, {}, env[:body]] }
-        stub.post('/reflect')     { |env| [200, {}, env[:body]] }
-        stub.get('/unauthorized') { |env| [401, {'Content-Type' => 'application/json'}, MultiJson.encode(:error => error_value, :error_description => error_description_value)] }
-        stub.get('/conflict')     { |env| [409, {'Content-Type' => 'text/plain'}, 'not authorized'] }
-        stub.get('/redirect')     { |env| [302, {'Content-Type' => 'text/plain', 'location' => '/success'}, ''] }
-        stub.post('/redirect')    { |env| [303, {'Content-Type' => 'text/plain', 'location' => '/reflect'}, ''] }
-        stub.get('/error')        { |env| [500, {'Content-Type' => 'text/plain'}, 'unknown error'] }
-        stub.get('/empty_get')    { |env| [204, {}, nil] }
-      end
-    end
-  end
-
-  describe '#initialize' do
-    it 'assigns id and secret' do
-      expect(subject.id).to eq('abc')
-      expect(subject.secret).to eq('def')
-    end
-
-    it 'assigns site from the options hash' do
-      expect(subject.site).to eq('https://api.example.com')
-    end
-
-    it 'assigns Faraday::Connection#host' do
-      expect(subject.connection.host).to eq('api.example.com')
-    end
-
-    it 'leaves Faraday::Connection#ssl unset' do
-      expect(subject.connection.ssl).to be_empty
-    end
-
-    it 'is able to pass a block to configure the connection' do
-      connection = double('connection')
-      builder = double('builder')
-      allow(connection).to receive(:build).and_yield(builder)
-      allow(Faraday::Connection).to receive(:new).and_return(connection)
-
-      expect(builder).to receive(:adapter).with(:test)
-
-      OAuth2::Client.new('abc', 'def') do |client|
-        client.adapter :test
-      end.connection
-    end
-
-    it 'defaults raise_errors to true' do
-      expect(subject.options[:raise_errors]).to be true
-    end
-
-    it 'allows true/false for raise_errors option' do
-      client = OAuth2::Client.new('abc', 'def', :site => 'https://api.example.com', :raise_errors => false)
-      expect(client.options[:raise_errors]).to be false
-      client = OAuth2::Client.new('abc', 'def', :site => 'https://api.example.com', :raise_errors => true)
-      expect(client.options[:raise_errors]).to be true
-    end
-
-    it 'allows override of raise_errors option' do
-      client = OAuth2::Client.new('abc', 'def', :site => 'https://api.example.com', :raise_errors => true) do |builder|
-        builder.adapter :test do |stub|
-          stub.get('/notfound') { |env| [404, {}, nil] }
-        end
-      end
-      expect(client.options[:raise_errors]).to be true
-      expect { client.request(:get, '/notfound') }.to raise_error(OAuth2::Error)
-      response = client.request(:get, '/notfound', :raise_errors => false)
-      expect(response.status).to eq(404)
-    end
-
-    it 'allows get/post for access_token_method option' do
-      client = OAuth2::Client.new('abc', 'def', :site => 'https://api.example.com', :access_token_method => :get)
-      expect(client.options[:access_token_method]).to eq(:get)
-      client = OAuth2::Client.new('abc', 'def', :site => 'https://api.example.com', :access_token_method => :post)
-      expect(client.options[:access_token_method]).to eq(:post)
-    end
-
-    it 'does not mutate the opts hash argument' do
-      opts = {:site => 'http://example.com/'}
-      opts2 = opts.dup
-      OAuth2::Client.new 'abc', 'def', opts
-      expect(opts).to eq(opts2)
-    end
-  end
-
-  %w(authorize token).each do |url_type|
-    describe ":#{url_type}_url option" do
-      it "defaults to a path of /oauth/#{url_type}" do
-        expect(subject.send("#{url_type}_url")).to eq("https://api.example.com/oauth/#{url_type}")
-      end
-
-      it "is settable via the :#{url_type}_url option" do
-        subject.options[:"#{url_type}_url"] = '/oauth/custom'
-        expect(subject.send("#{url_type}_url")).to eq('https://api.example.com/oauth/custom')
-      end
-
-      it 'allows a different host than the site' do
-        subject.options[:"#{url_type}_url"] = 'https://api.foo.com/oauth/custom'
-        expect(subject.send("#{url_type}_url")).to eq('https://api.foo.com/oauth/custom')
-      end
-    end
-  end
-
-  describe '#request' do
-    it 'works with a null response body' do
-      expect(subject.request(:get, 'empty_get').body).to eq('')
-    end
-
-    it 'returns on a successful response' do
-      response = subject.request(:get, '/success')
-      expect(response.body).to eq('yay')
-      expect(response.status).to eq(200)
-      expect(response.headers).to eq('Content-Type' => 'text/awesome')
-    end
-
-    it 'outputs to $stdout when OAUTH_DEBUG=true' do
-      allow(ENV).to receive(:[]).with('http_proxy').and_return(nil)
-      allow(ENV).to receive(:[]).with('OAUTH_DEBUG').and_return('true')
-      output = capture_output do
-        subject.request(:get, '/success')
-      end
-
-      expect(output).to include 'INFO -- : get https://api.example.com/success', 'INFO -- : get https://api.example.com/success'
-    end
-
-    it 'posts a body' do
-      response = subject.request(:post, '/reflect', :body => 'foo=bar')
-      expect(response.body).to eq('foo=bar')
-    end
-
-    it 'follows redirects properly' do
-      response = subject.request(:get, '/redirect')
-      expect(response.body).to eq('yay')
-      expect(response.status).to eq(200)
-      expect(response.headers).to eq('Content-Type' => 'text/awesome')
-    end
-
-    it 'redirects using GET on a 303' do
-      response = subject.request(:post, '/redirect', :body => 'foo=bar')
-      expect(response.body).to be_empty
-      expect(response.status).to eq(200)
-    end
-
-    it 'obeys the :max_redirects option' do
-      max_redirects = subject.options[:max_redirects]
-      subject.options[:max_redirects] = 0
-      response = subject.request(:get, '/redirect')
-      expect(response.status).to eq(302)
-      subject.options[:max_redirects] = max_redirects
-    end
-
-    it 'returns if raise_errors is false' do
-      subject.options[:raise_errors] = false
-      response = subject.request(:get, '/unauthorized')
-
-      expect(response.status).to eq(401)
-      expect(response.headers).to eq('Content-Type' => 'application/json')
-      expect(response.error).not_to be_nil
-    end
-
-    %w(/unauthorized /conflict /error).each do |error_path|
-      it "raises OAuth2::Error on error response to path #{error_path}" do
-        expect { subject.request(:get, error_path) }.to raise_error(OAuth2::Error)
-      end
-    end
-
-    it 'parses OAuth2 standard error response' do
-      begin
-        subject.request(:get, '/unauthorized')
-      rescue StandardError => e
-        expect(e.code).to eq(error_value)
-        expect(e.description).to eq(error_description_value)
-        expect(e.to_s).to match(/#{error_value}/)
-        expect(e.to_s).to match(/#{error_description_value}/)
-      end
-    end
-
-    it 'provides the response in the Exception' do
-      begin
-        subject.request(:get, '/error')
-      rescue StandardError => e
-        expect(e.response).not_to be_nil
-        expect(e.to_s).to match(/unknown error/)
-      end
-    end
-  end
-
-  it 'instantiates an AuthCode strategy with this client' do
-    expect(subject.auth_code).to be_kind_of(OAuth2::Strategy::AuthCode)
-  end
-
-  it 'instantiates an Implicit strategy with this client' do
-    expect(subject.implicit).to be_kind_of(OAuth2::Strategy::Implicit)
-  end
-
-  context 'with SSL options' do
-    subject do
-      cli = OAuth2::Client.new('abc', 'def', :site => 'https://api.example.com', :ssl => {:ca_file => 'foo.pem'})
-      cli.connection.build do |b|
-        b.adapter :test
-      end
-      cli
-    end
-
-    it 'passes the SSL options along to Faraday::Connection#ssl' do
-      expect(subject.connection.ssl.fetch(:ca_file)).to eq('foo.pem')
-    end
-  end
-end
diff --git a/spec/oauth2/mac_token_spec.rb b/spec/oauth2/mac_token_spec.rb
deleted file mode 100644
index 595a243..0000000
--- a/spec/oauth2/mac_token_spec.rb
+++ /dev/null
@@ -1,119 +0,0 @@
-require 'helper'
-
-describe MACToken do
-  let(:token) { 'monkey' }
-  let(:client) do
-    Client.new('abc', 'def', :site => 'https://api.example.com') do |builder|
-      builder.request :url_encoded
-      builder.adapter :test do |stub|
-        VERBS.each do |verb|
-          stub.send(verb, '/token/header') { |env| [200, {}, env[:request_headers]['Authorization']] }
-        end
-      end
-    end
-  end
-
-  subject { MACToken.new(client, token, 'abc123') }
-
-  describe '#initialize' do
-    it 'assigns client and token' do
-      expect(subject.client).to eq(client)
-      expect(subject.token).to eq(token)
-    end
-
-    it 'assigns secret' do
-      expect(subject.secret).to eq('abc123')
-    end
-
-    it 'defaults algorithm to hmac-sha-256' do
-      expect(subject.algorithm).to be_instance_of(OpenSSL::Digest::SHA256)
-    end
-
-    it 'handles hmac-sha-256' do
-      mac = MACToken.new(client, token, 'abc123', :algorithm => 'hmac-sha-256')
-      expect(mac.algorithm).to be_instance_of(OpenSSL::Digest::SHA256)
-    end
-
-    it 'handles hmac-sha-1' do
-      mac = MACToken.new(client, token, 'abc123', :algorithm => 'hmac-sha-1')
-      expect(mac.algorithm).to be_instance_of(OpenSSL::Digest::SHA1)
-    end
-
-    it 'raises on improper algorithm' do
-      expect { MACToken.new(client, token, 'abc123', :algorithm => 'invalid-sha') }.to raise_error(ArgumentError)
-    end
-  end
-
-  describe '#request' do
-    VERBS.each do |verb|
-      it "sends the token in the Authorization header for a #{verb.to_s.upcase} request" do
-        expect(subject.post('/token/header').body).to include("MAC id=\"#{token}\"")
-      end
-    end
-  end
-
-  describe '#header' do
-    it 'does not generate the same header twice' do
-      header = subject.header('get', 'https://www.example.com/hello')
-      duplicate_header = subject.header('get', 'https://www.example.com/hello')
-
-      expect(header).to_not eq(duplicate_header)
-    end
-
-    it 'generates the proper format' do
-      header = subject.header('get', 'https://www.example.com/hello?a=1')
-      expect(header).to match(/MAC id="#{token}", ts="[0-9]+", nonce="[^"]+", mac="[^"]+"/)
-    end
-
-    it 'passes ArgumentError with an invalid url' do
-      expect { subject.header('get', 'this-is-not-valid') }.to raise_error(ArgumentError)
-    end
-
-    it 'passes URI::InvalidURIError through' do
-      expect { subject.header('get', nil) }.to raise_error(URI::InvalidURIError)
-    end
-  end
-
-  describe '#signature' do
-    it 'generates properly' do
-      signature = subject.signature(0, 'random-string', 'get', URI('https://www.google.com'))
-      expect(signature).to eq('rMDjVA3VJj3v1OmxM29QQljKia6msl5rjN83x3bZmi8=')
-    end
-  end
-
-  describe '#headers' do
-    it 'is an empty hash' do
-      expect(subject.headers).to eq({})
-    end
-  end
-
-  describe '.from_access_token' do
-    let(:access_token) do
-      AccessToken.new(
-        client, token,
-        :expires_at => 1,
-        :expires_in => 1,
-        :refresh_token => 'abc',
-        :random => 1
-      )
-    end
-
-    subject { MACToken.from_access_token(access_token, 'hello') }
-
-    it 'initializes client, token, and secret properly' do
-      expect(subject.client).to eq(client)
-      expect(subject.token).to eq(token)
-      expect(subject.secret).to eq('hello')
-    end
-
-    it 'initializes configuration options' do
-      expect(subject.expires_at).to eq(1)
-      expect(subject.expires_in).to eq(1)
-      expect(subject.refresh_token).to eq('abc')
-    end
-
-    it 'initializes params' do
-      expect(subject.params).to eq(:random => 1)
-    end
-  end
-end
diff --git a/spec/oauth2/response_spec.rb b/spec/oauth2/response_spec.rb
deleted file mode 100644
index 7596f8c..0000000
--- a/spec/oauth2/response_spec.rb
+++ /dev/null
@@ -1,91 +0,0 @@
-require 'helper'
-
-describe OAuth2::Response do
-  describe '#initialize' do
-    let(:status) { 200 }
-    let(:headers) { {'foo' => 'bar'} }
-    let(:body) { 'foo' }
-
-    it 'returns the status, headers and body' do
-      response = double('response', :headers => headers,
-                                    :status  => status,
-                                    :body    => body)
-      subject = Response.new(response)
-      expect(subject.headers).to eq(headers)
-      expect(subject.status).to eq(status)
-      expect(subject.body).to eq(body)
-    end
-  end
-
-  describe '.register_parser' do
-    let(:response) do
-      double('response', :headers => {'Content-Type' => 'application/foo-bar'},
-                         :status => 200,
-                         :body => 'baz')
-    end
-    before do
-      OAuth2::Response.register_parser(:foobar, 'application/foo-bar') do |body|
-        "foobar #{body}"
-      end
-    end
-
-    it 'adds to the content types and parsers' do
-      expect(OAuth2::Response::PARSERS.keys).to include(:foobar)
-      expect(OAuth2::Response::CONTENT_TYPES.keys).to include('application/foo-bar')
-    end
-
-    it 'is able to parse that content type automatically' do
-      expect(OAuth2::Response.new(response).parsed).to eq('foobar baz')
-    end
-  end
-
-  describe '#parsed' do
-    it 'parses application/x-www-form-urlencoded body' do
-      headers = {'Content-Type' => 'application/x-www-form-urlencoded'}
-      body = 'foo=bar&answer=42'
-      response = double('response', :headers => headers, :body => body)
-      subject = Response.new(response)
-      expect(subject.parsed.keys.size).to eq(2)
-      expect(subject.parsed['foo']).to eq('bar')
-      expect(subject.parsed['answer']).to eq('42')
-    end
-
-    it 'parses application/json body' do
-      headers = {'Content-Type' => 'application/json'}
-      body = MultiJson.encode(:foo => 'bar', :answer => 42)
-      response = double('response', :headers => headers, :body => body)
-      subject = Response.new(response)
-      expect(subject.parsed.keys.size).to eq(2)
-      expect(subject.parsed['foo']).to eq('bar')
-      expect(subject.parsed['answer']).to eq(42)
-    end
-
-    it "doesn't try to parse other content-types" do
-      headers = {'Content-Type' => 'text/html'}
-      body = '<!DOCTYPE html><html><head></head><body></body></html>'
-
-      response = double('response', :headers => headers, :body => body)
-
-      expect(MultiJson).not_to receive(:decode)
-      expect(MultiJson).not_to receive(:load)
-      expect(Rack::Utils).not_to receive(:parse_query)
-
-      subject = Response.new(response)
-      expect(subject.parsed).to be_nil
-    end
-  end
-
-  context 'xml parser registration' do
-    it 'tries to load multi_xml and use it' do
-      expect(OAuth2::Response::PARSERS[:xml]).not_to be_nil
-    end
-
-    it 'is able to parse xml' do
-      headers = {'Content-Type' => 'text/xml'}
-      body = '<?xml version="1.0" standalone="yes" ?><foo><bar>baz</bar></foo>'
-
-      response = double('response', :headers => headers, :body => body)
-      expect(OAuth2::Response.new(response).parsed).to eq('foo' => {'bar' => 'baz'})
-    end
-  end
-end
diff --git a/spec/oauth2/strategy/assertion_spec.rb b/spec/oauth2/strategy/assertion_spec.rb
deleted file mode 100644
index 7a9aad6..0000000
--- a/spec/oauth2/strategy/assertion_spec.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-require 'helper'
-
-describe OAuth2::Strategy::Assertion do
-  let(:client) do
-    cli = OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com')
-    cli.connection.build do |b|
-      b.adapter :test do |stub|
-        stub.post('/oauth/token') do |env|
-          case @mode
-          when 'formencoded'
-            [200, {'Content-Type' => 'application/x-www-form-urlencoded'}, 'expires_in=600&access_token=salmon&refresh_token=trout']
-          when 'json'
-            [200, {'Content-Type' => 'application/json'}, '{"expires_in":600,"access_token":"salmon","refresh_token":"trout"}']
-          end
-        end
-      end
-    end
-    cli
-  end
-
-  let(:params) { {:hmac_secret => 'foo'} }
-
-  subject { client.assertion }
-
-  describe '#authorize_url' do
-    it 'raises NotImplementedError' do
-      expect { subject.authorize_url }.to raise_error(NotImplementedError)
-    end
-  end
-
-  %w(json formencoded).each do |mode|
-    describe "#get_token (#{mode})" do
-      before do
-        @mode = mode
-        @access = subject.get_token(params)
-      end
-
-      it 'returns AccessToken with same Client' do
-        expect(@access.client).to eq(client)
-      end
-
-      it 'returns AccessToken with #token' do
-        expect(@access.token).to eq('salmon')
-      end
-
-      it 'returns AccessToken with #expires_in' do
-        expect(@access.expires_in).to eq(600)
-      end
-
-      it 'returns AccessToken with #expires_at' do
-        expect(@access.expires_at).not_to be_nil
-      end
-    end
-  end
-
-end
diff --git a/spec/oauth2/strategy/auth_code_spec.rb b/spec/oauth2/strategy/auth_code_spec.rb
deleted file mode 100644
index a6f5768..0000000
--- a/spec/oauth2/strategy/auth_code_spec.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-require 'helper'
-
-describe OAuth2::Strategy::AuthCode do
-  let(:code) { 'sushi' }
-  let(:kvform_token) { 'expires_in=600&access_token=salmon&refresh_token=trout&extra_param=steve' }
-  let(:facebook_token) { kvform_token.gsub('_in', '') }
-  let(:json_token) { MultiJson.encode(:expires_in => 600, :access_token => 'salmon', :refresh_token => 'trout', :extra_param => 'steve') }
-
-  let(:client) do
-    OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com') do |builder|
-      builder.adapter :test do |stub|
-        stub.get("/oauth/token?client_id=abc&client_secret=def&code=#{code}&grant_type=authorization_code") do |env|
-          case @mode
-          when 'formencoded'
-            [200, {'Content-Type' => 'application/x-www-form-urlencoded'}, kvform_token]
-          when 'json'
-            [200, {'Content-Type' => 'application/json'}, json_token]
-          when 'from_facebook'
-            [200, {'Content-Type' => 'application/x-www-form-urlencoded'}, facebook_token]
-          end
-        end
-        stub.post('/oauth/token', 'client_id' => 'abc', 'client_secret' => 'def', 'code' => 'sushi', 'grant_type' => 'authorization_code') do |env|
-          case @mode
-          when 'formencoded'
-            [200, {'Content-Type' => 'application/x-www-form-urlencoded'}, kvform_token]
-          when 'json'
-            [200, {'Content-Type' => 'application/json'}, json_token]
-          when 'from_facebook'
-            [200, {'Content-Type' => 'application/x-www-form-urlencoded'}, facebook_token]
-          end
-        end
-      end
-    end
-  end
-
-  subject { client.auth_code }
-
-  describe '#authorize_url' do
-    it 'includes the client_id' do
-      expect(subject.authorize_url).to include('client_id=abc')
-    end
-
-    it 'includes the type' do
-      expect(subject.authorize_url).to include('response_type=code')
-    end
-
-    it 'includes passed in options' do
-      cb = 'http://myserver.local/oauth/callback'
-      expect(subject.authorize_url(:redirect_uri => cb)).to include("redirect_uri=#{Rack::Utils.escape(cb)}")
-    end
-  end
-
-  %w(json formencoded from_facebook).each do |mode|
-    [:get, :post].each do |verb|
-      describe "#get_token (#{mode}, access_token_method=#{verb}" do
-        before do
-          @mode = mode
-          client.options[:token_method] = verb
-          @access = subject.get_token(code)
-        end
-
-        it 'returns AccessToken with same Client' do
-          expect(@access.client).to eq(client)
-        end
-
-        it 'returns AccessToken with #token' do
-          expect(@access.token).to eq('salmon')
-        end
-
-        it 'returns AccessToken with #refresh_token' do
-          expect(@access.refresh_token).to eq('trout')
-        end
-
-        it 'returns AccessToken with #expires_in' do
-          expect(@access.expires_in).to eq(600)
-        end
-
-        it 'returns AccessToken with #expires_at' do
-          expect(@access.expires_at).to be_kind_of(Integer)
-        end
-
-        it 'returns AccessToken with params accessible via []' do
-          expect(@access['extra_param']).to eq('steve')
-        end
-      end
-    end
-  end
-end
diff --git a/spec/oauth2/strategy/base_spec.rb b/spec/oauth2/strategy/base_spec.rb
deleted file mode 100644
index 1174413..0000000
--- a/spec/oauth2/strategy/base_spec.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-require 'helper'
-
-describe OAuth2::Strategy::Base do
-  it 'initializes with a Client' do
-    expect { OAuth2::Strategy::Base.new(OAuth2::Client.new('abc', 'def')) }.not_to raise_error
-  end
-end
diff --git a/spec/oauth2/strategy/client_credentials_spec.rb b/spec/oauth2/strategy/client_credentials_spec.rb
deleted file mode 100644
index f6952aa..0000000
--- a/spec/oauth2/strategy/client_credentials_spec.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-require 'helper'
-
-describe OAuth2::Strategy::ClientCredentials do
-  let(:kvform_token) { 'expires_in=600&access_token=salmon&refresh_token=trout' }
-  let(:json_token) { '{"expires_in":600,"access_token":"salmon","refresh_token":"trout"}' }
-
-  let(:client) do
-    OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com') do |builder|
-      builder.adapter :test do |stub|
-        stub.post('/oauth/token', 'grant_type' => 'client_credentials') do |env|
-          client_id, client_secret = Base64.decode64(env[:request_headers]['Authorization'].split(' ', 2)[1]).split(':', 2)
-          client_id == 'abc' && client_secret == 'def' || fail(Faraday::Adapter::Test::Stubs::NotFound)
-          case @mode
-          when 'formencoded'
-            [200, {'Content-Type' => 'application/x-www-form-urlencoded'}, kvform_token]
-          when 'json'
-            [200, {'Content-Type' => 'application/json'}, json_token]
-          end
-        end
-        stub.post('/oauth/token', 'client_id' => 'abc', 'client_secret' => 'def', 'grant_type' => 'client_credentials') do |env|
-          case @mode
-          when 'formencoded'
-            [200, {'Content-Type' => 'application/x-www-form-urlencoded'}, kvform_token]
-          when 'json'
-            [200, {'Content-Type' => 'application/json'}, json_token]
-          end
-        end
-      end
-    end
-  end
-
-  subject { client.client_credentials }
-
-  describe '#authorize_url' do
-    it 'raises NotImplementedError' do
-      expect { subject.authorize_url }.to raise_error(NotImplementedError)
-    end
-  end
-
-  describe '#authorization' do
-    it 'generates an Authorization header value for HTTP Basic Authentication' do
-      [
-        ['abc', 'def', 'Basic YWJjOmRlZg=='],
-        ['xxx', 'secret', 'Basic eHh4OnNlY3JldA==']
-      ].each do |client_id, client_secret, expected|
-        expect(subject.authorization(client_id, client_secret)).to eq(expected)
-      end
-    end
-  end
-
-  %w(json formencoded).each do |mode|
-    %w(default basic_auth request_body).each do |auth_scheme|
-      describe "#get_token (#{mode}) (#{auth_scheme})" do
-        before do
-          @mode = mode
-          @access = subject.get_token({}, auth_scheme == 'default' ? {} : {'auth_scheme' => auth_scheme})
-        end
-
-        it 'returns AccessToken with same Client' do
-          expect(@access.client).to eq(client)
-        end
-
-        it 'returns AccessToken with #token' do
-          expect(@access.token).to eq('salmon')
-        end
-
-        it 'returns AccessToken without #refresh_token' do
-          expect(@access.refresh_token).to be_nil
-        end
-
-        it 'returns AccessToken with #expires_in' do
-          expect(@access.expires_in).to eq(600)
-        end
-
-        it 'returns AccessToken with #expires_at' do
-          expect(@access.expires_at).not_to be_nil
-        end
-      end
-    end
-  end
-end
diff --git a/spec/oauth2/strategy/implicit_spec.rb b/spec/oauth2/strategy/implicit_spec.rb
deleted file mode 100644
index af2d043..0000000
--- a/spec/oauth2/strategy/implicit_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'helper'
-
-describe OAuth2::Strategy::Implicit do
-  let(:client) { OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com') }
-
-  subject { client.implicit }
-
-  describe '#authorize_url' do
-    it 'includes the client_id' do
-      expect(subject.authorize_url).to include('client_id=abc')
-    end
-
-    it 'includes the type' do
-      expect(subject.authorize_url).to include('response_type=token')
-    end
-
-    it 'includes passed in options' do
-      cb = 'http://myserver.local/oauth/callback'
-      expect(subject.authorize_url(:redirect_uri => cb)).to include("redirect_uri=#{Rack::Utils.escape(cb)}")
-    end
-  end
-
-  describe '#get_token' do
-    it 'raises NotImplementedError' do
-      expect { subject.get_token }.to raise_error(NotImplementedError)
-    end
-  end
-end
diff --git a/spec/oauth2/strategy/password_spec.rb b/spec/oauth2/strategy/password_spec.rb
deleted file mode 100644
index ab03e69..0000000
--- a/spec/oauth2/strategy/password_spec.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-require 'helper'
-
-describe OAuth2::Strategy::Password do
-  let(:client) do
-    cli = OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com')
-    cli.connection.build do |b|
-      b.adapter :test do |stub|
-        stub.post('/oauth/token') do |env|
-          case @mode
-          when 'formencoded'
-            [200, {'Content-Type' => 'application/x-www-form-urlencoded'}, 'expires_in=600&access_token=salmon&refresh_token=trout']
-          when 'json'
-            [200, {'Content-Type' => 'application/json'}, '{"expires_in":600,"access_token":"salmon","refresh_token":"trout"}']
-          end
-        end
-      end
-    end
-    cli
-  end
-  subject { client.password }
-
-  describe '#authorize_url' do
-    it 'raises NotImplementedError' do
-      expect { subject.authorize_url }.to raise_error(NotImplementedError)
-    end
-  end
-
-  %w(json formencoded).each do |mode|
-    describe "#get_token (#{mode})" do
-      before do
-        @mode = mode
-        @access = subject.get_token('username', 'password')
-      end
-
-      it 'returns AccessToken with same Client' do
-        expect(@access.client).to eq(client)
-      end
-
-      it 'returns AccessToken with #token' do
-        expect(@access.token).to eq('salmon')
-      end
-
-      it 'returns AccessToken with #refresh_token' do
-        expect(@access.refresh_token).to eq('trout')
-      end
-
-      it 'returns AccessToken with #expires_in' do
-        expect(@access.expires_in).to eq(600)
-      end
-
-      it 'returns AccessToken with #expires_at' do
-        expect(@access.expires_at).not_to be_nil
-      end
-    end
-  end
-
-end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-oauth2.git



More information about the Pkg-ruby-extras-commits mailing list