rack-oauth2 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -1
  3. data/Rakefile +1 -1
  4. data/VERSION +1 -1
  5. data/lib/rack/oauth2/access_token/mac/verifier.rb +1 -1
  6. data/lib/rack/oauth2/access_token/mac.rb +26 -26
  7. data/lib/rack/oauth2/access_token.rb +7 -7
  8. data/lib/rack/oauth2/client/grant.rb +2 -2
  9. data/lib/rack/oauth2/client.rb +14 -13
  10. data/lib/rack/oauth2/server/abstract/error.rb +4 -4
  11. data/lib/rack/oauth2/server/abstract/request.rb +2 -2
  12. data/lib/rack/oauth2/server/authorize/code.rb +2 -2
  13. data/lib/rack/oauth2/server/authorize/error.rb +9 -9
  14. data/lib/rack/oauth2/server/authorize/extension/code_and_token.rb +2 -2
  15. data/lib/rack/oauth2/server/authorize.rb +2 -2
  16. data/lib/rack/oauth2/server/resource/error.rb +5 -5
  17. data/lib/rack/oauth2/server/resource.rb +1 -1
  18. data/lib/rack/oauth2/server/token/error.rb +7 -7
  19. data/lib/rack/oauth2/server/token.rb +1 -1
  20. data/lib/rack/oauth2.rb +1 -1
  21. data/spec/rack/oauth2/access_token/authenticator_spec.rb +6 -6
  22. data/spec/rack/oauth2/access_token/bearer_spec.rb +3 -3
  23. data/spec/rack/oauth2/access_token/legacy_spec.rb +3 -3
  24. data/spec/rack/oauth2/access_token/mac/sha256_hex_verifier_spec.rb +5 -5
  25. data/spec/rack/oauth2/access_token/mac/signature_spec.rb +26 -26
  26. data/spec/rack/oauth2/access_token/mac/verifier_spec.rb +3 -3
  27. data/spec/rack/oauth2/access_token/mac_spec.rb +20 -20
  28. data/spec/rack/oauth2/access_token_spec.rb +14 -14
  29. data/spec/rack/oauth2/client/error_spec.rb +4 -4
  30. data/spec/rack/oauth2/client/grant/authorization_code_spec.rb +5 -5
  31. data/spec/rack/oauth2/client/grant/client_credentials_spec.rb +2 -2
  32. data/spec/rack/oauth2/client/grant/password_spec.rb +4 -4
  33. data/spec/rack/oauth2/client/grant/refresh_token_spec.rb +3 -3
  34. data/spec/rack/oauth2/client_spec.rb +81 -45
  35. data/spec/rack/oauth2/debugger/request_filter_spec.rb +2 -2
  36. data/spec/rack/oauth2/server/abstract/error_spec.rb +8 -8
  37. data/spec/rack/oauth2/server/authorize/code_spec.rb +4 -4
  38. data/spec/rack/oauth2/server/authorize/error_spec.rb +5 -5
  39. data/spec/rack/oauth2/server/authorize/extensions/code_and_token_spec.rb +6 -6
  40. data/spec/rack/oauth2/server/authorize/token_spec.rb +6 -6
  41. data/spec/rack/oauth2/server/resource/bearer_spec.rb +4 -4
  42. data/spec/rack/oauth2/server/resource/error_spec.rb +3 -3
  43. data/spec/rack/oauth2/server/resource/mac_spec.rb +4 -4
  44. data/spec/rack/oauth2/server/token/authorization_code_spec.rb +7 -7
  45. data/spec/rack/oauth2/server/token/client_credentials_spec.rb +6 -6
  46. data/spec/rack/oauth2/server/token/password_spec.rb +7 -7
  47. data/spec/rack/oauth2/server/token/refresh_token_spec.rb +5 -5
  48. data/spec/rack/oauth2/server/token_spec.rb +14 -14
  49. data/spec/rack/oauth2/util_spec.rb +4 -4
  50. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0980862361a3371e8d3583498371e6b8be90f2e8
4
- data.tar.gz: fa10c1312d7a0ab9fb0f5d345f1c83bdddf6c2a0
3
+ metadata.gz: 8b5663f2b04727e356566085797919f0afc779bc
4
+ data.tar.gz: b5187b8a545bc9262e5d413c66a02f2135869ea4
5
5
  SHA512:
6
- metadata.gz: 5b778c7b605bd1c82a39b438b9e3172bb31bc25c1b6432234599987662d5be563aea479fd4beec66ef2cf0798f650e7043121c162d937de7832bbbe210791420
7
- data.tar.gz: 5755b4dff4fa248d32738dbf3840c272c41312d4f024e0aaba4f347a00f80c0518c0046ef074a722f30e38c527194ba4fcfadd1e1e24a8b5ad6fab790280e9c2
6
+ metadata.gz: 3e2e6b8ae412c89e5ed8784dd0bebf5992d986bb831de4b679a03693555decdd2cffbbe95eef65ad8f325f0f6abda5aac667e4d4f019c5bd501f3070df8f7f0c
7
+ data.tar.gz: 045edb07ca3c06cc65b6f3b25bcf4daca695e999366ef5d4d8b9e841744814eb37fff6088f8a1d06c24cc4706e99179aa57d33f1e007fa41f991bf704a357bf9
data/.travis.yml CHANGED
@@ -1,3 +1,5 @@
1
1
  rvm:
2
2
  - 1.9.3
3
- - 2.0.0
3
+ - 2.0.0
4
+ - 2.1.6
5
+ - 2.2.2
data/Rakefile CHANGED
@@ -16,4 +16,4 @@ task :spec do
16
16
  Rake::Task[:'coverage:report'].invoke unless ENV['TRAVIS_RUBY_VERSION']
17
17
  end
18
18
 
19
- task :default => :spec
19
+ task default: :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.2.0
@@ -41,4 +41,4 @@ module Rack
41
41
  end
42
42
  end
43
43
  end
44
- end
44
+ end
@@ -14,37 +14,37 @@ module Rack
14
14
 
15
15
  def token_response
16
16
  super.merge(
17
- :mac_key => mac_key,
18
- :mac_algorithm => mac_algorithm
17
+ mac_key: mac_key,
18
+ mac_algorithm: mac_algorithm
19
19
  )
20
20
  end
21
21
 
22
- def verify!(request)
22
+ def verify!(request)
23
23
  if self.ext_verifier.present?
24
24
  body = request.body.read
25
25
  request.body.rewind # for future use
26
26
 
27
27
  self.ext_verifier.new(
28
- :raw_body => body,
29
- :algorithm => self.mac_algorithm
28
+ raw_body: body,
29
+ algorithm: self.mac_algorithm
30
30
  ).verify!(request.ext)
31
31
  end
32
32
 
33
33
  now = Time.now.utc.to_i
34
34
  now = @ts.to_i if @ts.present?
35
-
35
+
36
36
  raise Rack::OAuth2::AccessToken::MAC::Verifier::VerificationFailed.new("Request ts expired") if now - request.ts.to_i > @ts_expires_in.to_i
37
37
 
38
38
  Signature.new(
39
- :secret => self.mac_key,
40
- :algorithm => self.mac_algorithm,
41
- :nonce => request.nonce,
42
- :method => request.request_method,
43
- :request_uri => request.fullpath,
44
- :host => request.host,
45
- :port => request.port,
46
- :ts => request.ts,
47
- :ext => request.ext
39
+ secret: self.mac_key,
40
+ algorithm: self.mac_algorithm,
41
+ nonce: request.nonce,
42
+ method: request.request_method,
43
+ request_uri: request.fullpath,
44
+ host: request.host,
45
+ port: request.port,
46
+ ts: request.ts,
47
+ ext: request.ext
48
48
  ).verify!(request.signature)
49
49
  rescue Verifier::VerificationFailed => e
50
50
  request.invalid_token! e.message
@@ -56,21 +56,21 @@ module Rack
56
56
 
57
57
  if self.ext_verifier.present?
58
58
  @ext = self.ext_verifier.new(
59
- :raw_body => request.body,
60
- :algorithm => self.mac_algorithm
59
+ raw_body: request.body,
60
+ algorithm: self.mac_algorithm
61
61
  ).calculate
62
62
  end
63
63
 
64
64
  @signature = Signature.new(
65
- :secret => self.mac_key,
66
- :algorithm => self.mac_algorithm,
67
- :nonce => self.nonce,
68
- :method => request.header.request_method,
69
- :request_uri => request.header.create_query_uri,
70
- :host => request.header.request_uri.host,
71
- :port => request.header.request_uri.port,
72
- :ts => @ts_generated,
73
- :ext => @ext
65
+ secret: self.mac_key,
66
+ algorithm: self.mac_algorithm,
67
+ nonce: self.nonce,
68
+ method: request.header.request_method,
69
+ request_uri: request.header.create_query_uri,
70
+ host: request.header.request_uri.host,
71
+ port: request.header.request_uri.port,
72
+ ts: @ts_generated,
73
+ ext: @ext
74
74
  ).calculate
75
75
 
76
76
  request.header['Authorization'] = authorization_header
@@ -4,7 +4,7 @@ module Rack
4
4
  include AttrRequired, AttrOptional
5
5
  attr_required :access_token, :token_type, :httpclient
6
6
  attr_optional :refresh_token, :expires_in, :scope
7
- delegate :get, :post, :put, :delete, :to => :httpclient
7
+ delegate :get, :post, :put, :delete, to: :httpclient
8
8
 
9
9
  alias_method :to_s, :access_token
10
10
 
@@ -21,11 +21,11 @@ module Rack
21
21
 
22
22
  def token_response(options = {})
23
23
  {
24
- :access_token => access_token,
25
- :refresh_token => refresh_token,
26
- :token_type => token_type,
27
- :expires_in => expires_in,
28
- :scope => Array(scope).join(' ')
24
+ access_token: access_token,
25
+ refresh_token: refresh_token,
26
+ token_type: token_type,
27
+ expires_in: expires_in,
28
+ scope: Array(scope).join(' ')
29
29
  }
30
30
  end
31
31
  end
@@ -35,4 +35,4 @@ end
35
35
  require 'rack/oauth2/access_token/authenticator'
36
36
  require 'rack/oauth2/access_token/bearer'
37
37
  require 'rack/oauth2/access_token/mac'
38
- require 'rack/oauth2/access_token/legacy'
38
+ require 'rack/oauth2/access_token/legacy'
@@ -13,7 +13,7 @@ module Rack
13
13
 
14
14
  def as_json(options = {})
15
15
  (required_attributes + optional_attributes).inject({
16
- :grant_type => self.class.name.demodulize.underscore.to_sym
16
+ grant_type: self.class.name.demodulize.underscore.to_sym
17
17
  }) do |hash, key|
18
18
  hash.merge! key => self.send(key)
19
19
  end
@@ -26,4 +26,4 @@ end
26
26
  require 'rack/oauth2/client/grant/authorization_code'
27
27
  require 'rack/oauth2/client/grant/password'
28
28
  require 'rack/oauth2/client/grant/client_credentials'
29
- require 'rack/oauth2/client/grant/refresh_token'
29
+ require 'rack/oauth2/client/grant/refresh_token'
@@ -20,28 +20,28 @@ module Rack
20
20
  params[:response_type] = Array(params[:response_type]).join(' ')
21
21
  params[:scope] = Array(params[:scope]).join(' ')
22
22
  Util.redirect_uri absolute_uri_for(authorization_endpoint), :query, params.merge(
23
- :client_id => self.identifier,
24
- :redirect_uri => self.redirect_uri
23
+ client_id: self.identifier,
24
+ redirect_uri: self.redirect_uri
25
25
  )
26
26
  end
27
27
 
28
28
  def authorization_code=(code)
29
29
  @grant = Grant::AuthorizationCode.new(
30
- :code => code,
31
- :redirect_uri => self.redirect_uri
30
+ code: code,
31
+ redirect_uri: self.redirect_uri
32
32
  )
33
33
  end
34
34
 
35
35
  def resource_owner_credentials=(credentials)
36
36
  @grant = Grant::Password.new(
37
- :username => credentials.first,
38
- :password => credentials.last
37
+ username: credentials.first,
38
+ password: credentials.last
39
39
  )
40
40
  end
41
41
 
42
42
  def refresh_token=(token)
43
43
  @grant = Grant::RefreshToken.new(
44
- :refresh_token => token
44
+ refresh_token: token
45
45
  )
46
46
  end
47
47
 
@@ -52,9 +52,10 @@ module Rack
52
52
  # Using Array#estract_options! for backward compatibility.
53
53
  # Until v1.0.5, the first argument was 'client_auth_method' in scalar.
54
54
  options = args.extract_options!
55
- client_auth_method = args.first || options[:client_auth_method] || :basic
55
+ client_auth_method = args.first || options.delete(:client_auth_method) || :basic
56
56
 
57
- params[:scope] = Array(options[:scope]).join(' ') if options[:scope].present?
57
+ params[:scope] = Array(options.delete(:scope)).join(' ') if options[:scope].present?
58
+ params.merge! options
58
59
 
59
60
  if secret && client_auth_method == :basic
60
61
  cred = ["#{identifier}:#{secret}"].pack('m').tr("\n", '')
@@ -63,8 +64,8 @@ module Rack
63
64
  )
64
65
  else
65
66
  params.merge!(
66
- :client_id => identifier,
67
- :client_secret => secret
67
+ client_id: identifier,
68
+ client_secret: secret
68
69
  )
69
70
  end
70
71
  handle_response do
@@ -118,7 +119,7 @@ module Rack
118
119
  error = parse_json response.body
119
120
  raise Error.new(response.status, error)
120
121
  rescue MultiJson::DecodeError
121
- raise Error.new(response.status, :error => 'Unknown', :error_description => response.body)
122
+ raise Error.new(response.status, error: 'Unknown', error_description: response.body)
122
123
  end
123
124
 
124
125
  def parse_json(raw_json)
@@ -130,4 +131,4 @@ module Rack
130
131
  end
131
132
 
132
133
  require 'rack/oauth2/client/error'
133
- require 'rack/oauth2/client/grant'
134
+ require 'rack/oauth2/client/grant'
@@ -16,9 +16,9 @@ module Rack
16
16
 
17
17
  def protocol_params
18
18
  {
19
- :error => error,
20
- :error_description => description,
21
- :error_uri => uri
19
+ error: error,
20
+ error_description: description,
21
+ error_uri: uri
22
22
  }
23
23
  end
24
24
 
@@ -66,4 +66,4 @@ module Rack
66
66
  end
67
67
  end
68
68
  end
69
- end
69
+ end
@@ -19,11 +19,11 @@ module Rack
19
19
  end
20
20
  attr_missing_without_error_handling!
21
21
  rescue AttrRequired::AttrMissing => e
22
- invalid_request! e.message, :state => @state, :redirect_uri => @redirect_uri
22
+ invalid_request! e.message, state: @state, redirect_uri: @redirect_uri
23
23
  end
24
24
  alias_method_chain :attr_missing!, :error_handling
25
25
  end
26
26
  end
27
27
  end
28
28
  end
29
- end
29
+ end
@@ -25,7 +25,7 @@ module Rack
25
25
  attr_required :code
26
26
 
27
27
  def protocol_params
28
- super.merge(:code => code)
28
+ super.merge(code: code)
29
29
  end
30
30
 
31
31
  def protocol_params_location
@@ -36,4 +36,4 @@ module Rack
36
36
  end
37
37
  end
38
38
  end
39
- end
39
+ end
@@ -8,7 +8,7 @@ module Rack
8
8
  end
9
9
 
10
10
  def protocol_params
11
- super.merge(:state => state)
11
+ super.merge(state: state)
12
12
  end
13
13
 
14
14
  def finish
@@ -36,13 +36,13 @@ module Rack
36
36
 
37
37
  module ErrorMethods
38
38
  DEFAULT_DESCRIPTION = {
39
- :invalid_request => "The request is missing a required parameter, includes an unsupported parameter or parameter value, or is otherwise malformed.",
40
- :unauthorized_client => "The client is not authorized to use the requested response type.",
41
- :access_denied => "The end-user or authorization server denied the request.",
42
- :unsupported_response_type => "The requested response type is not supported by the authorization server.",
43
- :invalid_scope => "The requested scope is invalid, unknown, or malformed.",
44
- :server_error => "Internal Server Error",
45
- :temporarily_unavailable => "Service Unavailable"
39
+ invalid_request: "The request is missing a required parameter, includes an unsupported parameter or parameter value, or is otherwise malformed.",
40
+ unauthorized_client: "The client is not authorized to use the requested response type.",
41
+ access_denied: "The end-user or authorization server denied the request.",
42
+ unsupported_response_type: "The requested response type is not supported by the authorization server.",
43
+ invalid_scope: "The requested scope is invalid, unknown, or malformed.",
44
+ server_error: "Internal Server Error",
45
+ temporarily_unavailable: "Service Unavailable"
46
46
  }
47
47
 
48
48
  def self.included(klass)
@@ -87,4 +87,4 @@ module Rack
87
87
  end
88
88
  end
89
89
  end
90
- end
90
+ end
@@ -28,7 +28,7 @@ module Rack
28
28
  attr_required :code
29
29
 
30
30
  def protocol_params
31
- super.merge(:code => code)
31
+ super.merge(code: code)
32
32
  end
33
33
  end
34
34
  end
@@ -36,4 +36,4 @@ module Rack
36
36
  end
37
37
  end
38
38
  end
39
- end
39
+ end
@@ -91,7 +91,7 @@ module Rack
91
91
  end
92
92
 
93
93
  def protocol_params
94
- {:state => state}
94
+ {state: state}
95
95
  end
96
96
 
97
97
  def redirect_uri_with_credentials
@@ -114,4 +114,4 @@ end
114
114
  require 'rack/oauth2/server/authorize/code'
115
115
  require 'rack/oauth2/server/authorize/token'
116
116
  require 'rack/oauth2/server/authorize/extension'
117
- require 'rack/oauth2/server/authorize/error'
117
+ require 'rack/oauth2/server/authorize/error'
@@ -32,15 +32,15 @@ module Rack
32
32
  end
33
33
 
34
34
  def protocol_params
35
- super.merge(:scope => Array(scope).join(' '))
35
+ super.merge(scope: Array(scope).join(' '))
36
36
  end
37
37
  end
38
38
 
39
39
  module ErrorMethods
40
40
  DEFAULT_DESCRIPTION = {
41
- :invalid_request => "The request is missing a required parameter, includes an unsupported parameter or parameter value, repeats the same parameter, uses more than one method for including an access token, or is otherwise malformed.",
42
- :invalid_token => "The access token provided is expired, revoked, malformed or invalid for other reasons.",
43
- :insufficient_scope => "The request requires higher privileges than provided by the access token."
41
+ invalid_request: "The request is missing a required parameter, includes an unsupported parameter or parameter value, repeats the same parameter, uses more than one method for including an access token, or is otherwise malformed.",
42
+ invalid_token: "The access token provided is expired, revoked, malformed or invalid for other reasons.",
43
+ insufficient_scope: "The request requires higher privileges than provided by the access token."
44
44
  }
45
45
 
46
46
  def self.included(klass)
@@ -78,4 +78,4 @@ module Rack
78
78
  end
79
79
  end
80
80
  end
81
- end
81
+ end
@@ -52,4 +52,4 @@ end
52
52
 
53
53
  require 'rack/oauth2/server/resource/error'
54
54
  require 'rack/oauth2/server/resource/bearer'
55
- require 'rack/oauth2/server/resource/mac'
55
+ require 'rack/oauth2/server/resource/mac'
@@ -15,12 +15,12 @@ module Rack
15
15
 
16
16
  module ErrorMethods
17
17
  DEFAULT_DESCRIPTION = {
18
- :invalid_request => "The request is missing a required parameter, includes an unsupported parameter or parameter value, repeats a parameter, includes multiple credentials, utilizes more than one mechanism for authenticating the client, or is otherwise malformed.",
19
- :invalid_client => "The client identifier provided is invalid, the client failed to authenticate, the client did not include its credentials, provided multiple client credentials, or used unsupported credentials type.",
20
- :invalid_grant => "The provided access grant is invalid, expired, or revoked (e.g. invalid assertion, expired authorization token, bad end-user password credentials, or mismatching authorization code and redirection URI).",
21
- :unauthorized_client => "The authenticated client is not authorized to use the access grant type provided.",
22
- :unsupported_grant_type => "The access grant included - its type or another attribute - is not supported by the authorization server.",
23
- :invalid_scope => "The requested scope is invalid, unknown, malformed, or exceeds the previously granted scope."
18
+ invalid_request: "The request is missing a required parameter, includes an unsupported parameter or parameter value, repeats a parameter, includes multiple credentials, utilizes more than one mechanism for authenticating the client, or is otherwise malformed.",
19
+ invalid_client: "The client identifier provided is invalid, the client failed to authenticate, the client did not include its credentials, provided multiple client credentials, or used unsupported credentials type.",
20
+ invalid_grant: "The provided access grant is invalid, expired, or revoked (e.g. invalid assertion, expired authorization token, bad end-user password credentials, or mismatching authorization code and redirection URI).",
21
+ unauthorized_client: "The authenticated client is not authorized to use the access grant type provided.",
22
+ unsupported_grant_type: "The access grant included - its type or another attribute - is not supported by the authorization server.",
23
+ invalid_scope: "The requested scope is invalid, unknown, malformed, or exceeds the previously granted scope."
24
24
  }
25
25
 
26
26
  def self.included(klass)
@@ -51,4 +51,4 @@ module Rack
51
51
  end
52
52
  end
53
53
  end
54
- end
54
+ end
@@ -81,4 +81,4 @@ require 'rack/oauth2/server/token/password'
81
81
  require 'rack/oauth2/server/token/client_credentials'
82
82
  require 'rack/oauth2/server/token/refresh_token'
83
83
  require 'rack/oauth2/server/token/extension'
84
- require 'rack/oauth2/server/token/error'
84
+ require 'rack/oauth2/server/token/error'
data/lib/rack/oauth2.rb CHANGED
@@ -42,7 +42,7 @@ module Rack
42
42
 
43
43
  def self.http_client(agent_name = "Rack::OAuth2 (#{VERSION})", &local_http_config)
44
44
  _http_client_ = HTTPClient.new(
45
- :agent_name => agent_name
45
+ agent_name: agent_name
46
46
  )
47
47
  http_config.try(:call, _http_client_)
48
48
  local_http_config.try(:call, _http_client_) unless local_http_config.nil?
@@ -15,7 +15,7 @@ describe Rack::OAuth2::AccessToken::Authenticator do
15
15
  context 'when Legacy token is given' do
16
16
  let(:token) do
17
17
  Rack::OAuth2::AccessToken::Legacy.new(
18
- :access_token => 'access_token'
18
+ access_token: 'access_token'
19
19
  )
20
20
  end
21
21
  it_behaves_like :authenticator
@@ -24,7 +24,7 @@ describe Rack::OAuth2::AccessToken::Authenticator do
24
24
  context 'when Bearer token is given' do
25
25
  let(:token) do
26
26
  Rack::OAuth2::AccessToken::Bearer.new(
27
- :access_token => 'access_token'
27
+ access_token: 'access_token'
28
28
  )
29
29
  end
30
30
  it_behaves_like :authenticator
@@ -33,11 +33,11 @@ describe Rack::OAuth2::AccessToken::Authenticator do
33
33
  context 'when MAC token is given' do
34
34
  let(:token) do
35
35
  Rack::OAuth2::AccessToken::MAC.new(
36
- :access_token => 'access_token',
37
- :mac_key => 'secret',
38
- :mac_algorithm => 'hmac-sha-256'
36
+ access_token: 'access_token',
37
+ mac_key: 'secret',
38
+ mac_algorithm: 'hmac-sha-256'
39
39
  )
40
40
  end
41
41
  it_behaves_like :authenticator
42
42
  end
43
- end
43
+ end
@@ -3,11 +3,11 @@ require 'spec_helper'
3
3
  describe Rack::OAuth2::AccessToken::Bearer do
4
4
  let :token do
5
5
  Rack::OAuth2::AccessToken::Bearer.new(
6
- :access_token => 'access_token'
6
+ access_token: 'access_token'
7
7
  )
8
8
  end
9
9
  let(:resource_endpoint) { 'https://server.example.com/resources/fake' }
10
- let(:request) { HTTPClient.new.send(:create_request, :post, URI.parse(resource_endpoint), {}, {:hello => "world"}, {}) }
10
+ let(:request) { HTTPClient.new.send(:create_request, :post, URI.parse(resource_endpoint), {}, {hello: "world"}, {}) }
11
11
 
12
12
  describe '.authenticate' do
13
13
  it 'should set Authorization header' do
@@ -15,4 +15,4 @@ describe Rack::OAuth2::AccessToken::Bearer do
15
15
  token.authenticate(request)
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -3,11 +3,11 @@ require 'spec_helper'
3
3
  describe Rack::OAuth2::AccessToken::Legacy do
4
4
  let :token do
5
5
  Rack::OAuth2::AccessToken::Legacy.new(
6
- :access_token => 'access_token'
6
+ access_token: 'access_token'
7
7
  )
8
8
  end
9
9
  let(:resource_endpoint) { 'https://server.example.com/resources/fake' }
10
- let(:request) { HTTPClient.new.send(:create_request, :post, URI.parse(resource_endpoint), {}, {:hello => "world"}, {}) }
10
+ let(:request) { HTTPClient.new.send(:create_request, :post, URI.parse(resource_endpoint), {}, {hello: "world"}, {}) }
11
11
 
12
12
  describe '#to_s' do
13
13
  subject { token }
@@ -20,4 +20,4 @@ describe Rack::OAuth2::AccessToken::Legacy do
20
20
  token.authenticate(request)
21
21
  end
22
22
  end
23
- end
23
+ end
@@ -7,8 +7,8 @@ describe Rack::OAuth2::AccessToken::MAC::Sha256HexVerifier do
7
7
  context 'when example from webtopay wallet API' do
8
8
  subject do
9
9
  Rack::OAuth2::AccessToken::MAC::Sha256HexVerifier.new(
10
- :algorithm => 'hmac-sha-256',
11
- :raw_body => 'grant_type=authorization_code&code=SplxlOBeZQQYbYS6WxSbIA&redirect_uri=http%3A%2F%2Flocalhost%2Fabc'
10
+ algorithm: 'hmac-sha-256',
11
+ raw_body: 'grant_type=authorization_code&code=SplxlOBeZQQYbYS6WxSbIA&redirect_uri=http%3A%2F%2Flocalhost%2Fabc'
12
12
  )
13
13
  end
14
14
  its(:calculate) { should == '21fb73c40b589622d0c78e9cd8900f89d9472aa724d0e5c3eca9ac1cd9d2a6d5' }
@@ -18,11 +18,11 @@ describe Rack::OAuth2::AccessToken::MAC::Sha256HexVerifier do
18
18
  context 'when raw_body is empty' do
19
19
  subject do
20
20
  Rack::OAuth2::AccessToken::MAC::Sha256HexVerifier.new(
21
- :algorithm => 'hmac-sha-256',
22
- :raw_body => ''
21
+ algorithm: 'hmac-sha-256',
22
+ raw_body: ''
23
23
  )
24
24
  end
25
25
  its(:calculate) { should be_nil }
26
26
  end
27
27
 
28
- end
28
+ end
@@ -6,14 +6,14 @@ describe Rack::OAuth2::AccessToken::MAC::Signature do
6
6
  context 'when ext is not given' do
7
7
  subject do
8
8
  Rack::OAuth2::AccessToken::MAC::Signature.new(
9
- :secret => 'IrdTc8uQodU7PRpLzzLTW6wqZAO6tAMU',
10
- :algorithm => 'hmac-sha-256',
11
- :nonce => 'dj83hs9s',
12
- :ts => 1336363200,
13
- :method => 'GET',
14
- :request_uri => '/wallet/rest/api/v1/payment/123',
15
- :host => 'www.webtopay.com',
16
- :port => 443
9
+ secret: 'IrdTc8uQodU7PRpLzzLTW6wqZAO6tAMU',
10
+ algorithm: 'hmac-sha-256',
11
+ nonce: 'dj83hs9s',
12
+ ts: 1336363200,
13
+ method: 'GET',
14
+ request_uri: '/wallet/rest/api/v1/payment/123',
15
+ host: 'www.webtopay.com',
16
+ port: 443
17
17
  )
18
18
  end
19
19
  its(:calculate) { should == 'OZE9fTk2qiRtL1jb01L8lRxC66PTiAGhMDEmboeVeLs=' }
@@ -24,14 +24,14 @@ describe Rack::OAuth2::AccessToken::MAC::Signature do
24
24
  context 'when ext is not given' do
25
25
  subject do
26
26
  Rack::OAuth2::AccessToken::MAC::Signature.new(
27
- :secret => '489dks293j39',
28
- :algorithm => 'hmac-sha-1',
29
- :nonce => 'dj83hs9s',
30
- :ts => 1336363200,
31
- :method => 'GET',
32
- :request_uri => '/resource/1?b=1&a=2',
33
- :host => 'example.com',
34
- :port => 80
27
+ secret: '489dks293j39',
28
+ algorithm: 'hmac-sha-1',
29
+ nonce: 'dj83hs9s',
30
+ ts: 1336363200,
31
+ method: 'GET',
32
+ request_uri: '/resource/1?b=1&a=2',
33
+ host: 'example.com',
34
+ port: 80
35
35
  )
36
36
  end
37
37
  its(:calculate) { should == '6T3zZzy2Emppni6bzL7kdRxUWL4=' }
@@ -42,18 +42,18 @@ describe Rack::OAuth2::AccessToken::MAC::Signature do
42
42
  context 'otherwise' do
43
43
  subject do
44
44
  Rack::OAuth2::AccessToken::MAC::Signature.new(
45
- :secret => '489dks293j39',
46
- :algorithm => 'hmac-sha-1',
47
- :nonce => '7d8f3e4a',
48
- :ts => 264095,
49
- :method => 'POST',
50
- :request_uri => '/request?b5=%3D%253D&a3=a&c%40=&a2=r%20b&c2&a3=2+q',
51
- :host => 'example.com',
52
- :port => 80,
53
- :ext => 'a,b,c'
45
+ secret: '489dks293j39',
46
+ algorithm: 'hmac-sha-1',
47
+ nonce: '7d8f3e4a',
48
+ ts: 264095,
49
+ method: 'POST',
50
+ request_uri: '/request?b5=%3D%253D&a3=a&c%40=&a2=r%20b&c2&a3=2+q',
51
+ host: 'example.com',
52
+ port: 80,
53
+ ext: 'a,b,c'
54
54
  )
55
55
  end
56
56
  its(:calculate) { should == '+txL5oOFHGYjrfdNYH5VEzROaBY=' }
57
57
  end
58
58
 
59
- end
59
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Rack::OAuth2::AccessToken::MAC::Verifier do
4
- let(:verifier) { Rack::OAuth2::AccessToken::MAC::Verifier.new(:algorithm => algorithm) }
4
+ let(:verifier) { Rack::OAuth2::AccessToken::MAC::Verifier.new(algorithm: algorithm) }
5
5
  subject { verifier }
6
6
 
7
7
  context 'when "hmac-sha-1" is specified' do
@@ -21,5 +21,5 @@ describe Rack::OAuth2::AccessToken::MAC::Verifier do
21
21
  end
22
22
  end
23
23
 
24
-
25
- end
24
+
25
+ end