rack-oauth2 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d323b7513cd60355bbdf46ce163a68f6e75f63cb
4
- data.tar.gz: f508b741b88d65f5bf09ab18d6b679014cfacb3d
3
+ metadata.gz: 85fbc5f6cc2f9216589bebdf3f9e56e0a3b2af4a
4
+ data.tar.gz: 9c9774de8ba9e8b4bd4ff346dec70626105ebea1
5
5
  SHA512:
6
- metadata.gz: fc1f0130aecb1bb3eb84d5b2f4bf49ff22de41b21cbb64bbf150e6c98c9e5d89cfe61fda81757f180cabe96d3e630c2e9a502375c2a0e96da3f9ba3634aa7ab0
7
- data.tar.gz: 1d2ab83033f3609f6a0458034917fcc1954ff419cd77e247c4d06fb0de2008192ebd5e1aa9d9804e8a05d7269586ed6f924972087d0e3d0b8863b4d92b91d78e
6
+ metadata.gz: 989642e1ae224eee2deab2738024d2214fe2b3478f13367be33371af8141297ce363d8ae8845acf4117a1da13ca320c6932d3bc74f77964ca7facc825fcf4c07
7
+ data.tar.gz: 58c119cabf5525303d7166a34833196c63814a4082bfb13a5744eafc4fb2faee66de32b628e357d9e6881b5b553acf4b80f8487b203ccff23771be54907aa589
data/README.rdoc CHANGED
@@ -21,9 +21,8 @@ http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01
21
21
  == Resources
22
22
 
23
23
  * View Source on GitHub (https://github.com/nov/rack-oauth2)
24
+ * Docs on GitHub (https://github.com/nov/rack-oauth2/wiki)
24
25
  * Report Issues on GitHub (https://github.com/nov/rack-oauth2/issues)
25
- * Subscribe Update Info (https://www.facebook.com/rackoauth2)
26
- * Q&A on Google Groups (https://groups.google.com/group/rack-oauth2)
27
26
 
28
27
  == Sample Server Application (Rails3)
29
28
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.8
1
+ 1.0.9
data/lib/rack/oauth2.rb CHANGED
@@ -2,7 +2,8 @@ require 'rack'
2
2
  require 'multi_json'
3
3
  require 'httpclient'
4
4
  require 'logger'
5
- require 'active_support/all'
5
+ require 'active_support'
6
+ require 'active_support/core_ext'
6
7
  require 'attr_required'
7
8
  require 'attr_optional'
8
9
 
@@ -47,7 +47,7 @@ module Rack
47
47
  given.path = '/' if given.path.blank?
48
48
  [:scheme, :host, :port].all? do |key|
49
49
  base.send(key) == given.send(key)
50
- end && /^#{base.path}/ =~ given.path
50
+ end && !!(/^#{base.path}/ =~ given.path)
51
51
  rescue
52
52
  false
53
53
  end
data/rack-oauth2.gemspec CHANGED
@@ -16,11 +16,12 @@ Gem::Specification.new do |s|
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
17
  s.add_runtime_dependency "rack", ">= 1.1"
18
18
  s.add_runtime_dependency "multi_json", ">= 1.3.6"
19
- s.add_runtime_dependency "httpclient", ">= 2.2.0.2"
19
+ s.add_runtime_dependency "httpclient", ">= 2.4"
20
20
  s.add_runtime_dependency "activesupport", ">= 2.3"
21
21
  s.add_runtime_dependency "attr_required", ">= 0.0.5"
22
22
  s.add_development_dependency "rake", ">= 0.8"
23
23
  s.add_development_dependency "simplecov"
24
- s.add_development_dependency "rspec", ">= 2"
25
- s.add_development_dependency "webmock", ">= 1.6.2"
24
+ s.add_development_dependency "rspec"
25
+ s.add_development_dependency "rspec-its"
26
+ s.add_development_dependency "webmock"
26
27
  end
@@ -13,13 +13,12 @@ module WebMockHelper
13
13
 
14
14
  def request_for(method, options = {})
15
15
  request = {}
16
- if options[:params]
17
- case method
18
- when :post, :put
19
- request[:body] = options[:params]
20
- else
21
- request[:query] = options[:params]
22
- end
16
+ params = options.try(:[], :params) || {}
17
+ case method
18
+ when :post, :put, :delete
19
+ request[:body] = params
20
+ else
21
+ request[:query] = params
23
22
  end
24
23
  if options[:request_header]
25
24
  request[:headers] = options[:request_header]
@@ -7,7 +7,7 @@ describe Rack::OAuth2::AccessToken::Authenticator do
7
7
 
8
8
  shared_examples_for :authenticator do
9
9
  it 'should let the token authenticate the request' do
10
- token.should_receive(:authenticate).with(request)
10
+ expect(token).to receive(:authenticate).with(request)
11
11
  authenticator.filter_request(request)
12
12
  end
13
13
  end
@@ -11,7 +11,7 @@ describe Rack::OAuth2::AccessToken::Bearer do
11
11
 
12
12
  describe '.authenticate' do
13
13
  it 'should set Authorization header' do
14
- request.header.should_receive(:[]=).with('Authorization', 'Bearer access_token')
14
+ expect(request.header).to receive(:[]=).with('Authorization', 'Bearer access_token')
15
15
  token.authenticate(request)
16
16
  end
17
17
  end
@@ -16,7 +16,7 @@ describe Rack::OAuth2::AccessToken::Legacy do
16
16
 
17
17
  describe '.authenticate' do
18
18
  it 'should set Authorization header' do
19
- request.header.should_receive(:[]=).with('Authorization', 'OAuth access_token')
19
+ expect(request.header).to receive(:[]=).with('Authorization', 'OAuth access_token')
20
20
  token.authenticate(request)
21
21
  end
22
22
  end
@@ -121,8 +121,8 @@ describe Rack::OAuth2::AccessToken::MAC do
121
121
  let(:signature) { 'pOBaL6HRawe4tUPmcU4vJEj1f2GJqrbQOlCcdAYgI/s=' }
122
122
 
123
123
  it 'should set Authorization header' do
124
- token.should_receive(:generate_nonce).and_return(nonce)
125
- request.header.should_receive(:[]=).with('Authorization', "MAC id=\"access_token\", nonce=\"#{nonce}\", ts=\"#{ts.to_i}\", mac=\"#{signature}\"")
124
+ expect(token).to receive(:generate_nonce).and_return(nonce)
125
+ expect(request.header).to receive(:[]=).with('Authorization', "MAC id=\"access_token\", nonce=\"#{nonce}\", ts=\"#{ts.to_i}\", mac=\"#{signature}\"")
126
126
  token.authenticate(request)
127
127
  end
128
128
  end
@@ -131,8 +131,8 @@ describe Rack::OAuth2::AccessToken::MAC do
131
131
  let(:signature) { 'vgU0fj6rSpwUCAoCOrXlu8pZBR8a5Q5xIVlB4MCvJeM=' }
132
132
  let(:ext) { '3d011e09502a84552a0f8ae112d024cc2c115597e3a577d5f49007902c221dc5' }
133
133
  it 'should set Authorization header with ext_verifier' do
134
- token_with_ext_verifier.should_receive(:generate_nonce).and_return(nonce)
135
- request.header.should_receive(:[]=).with('Authorization', "MAC id=\"access_token\", nonce=\"#{nonce}\", ts=\"#{ts.to_i}\", mac=\"#{signature}\", ext=\"#{ext}\"")
134
+ expect(token_with_ext_verifier).to receive(:generate_nonce).and_return(nonce)
135
+ expect(request.header).to receive(:[]=).with('Authorization', "MAC id=\"access_token\", nonce=\"#{nonce}\", ts=\"#{ts.to_i}\", mac=\"#{signature}\", ext=\"#{ext}\"")
136
136
  token_with_ext_verifier.authenticate(request)
137
137
  end
138
138
  end
@@ -51,7 +51,7 @@ describe Rack::OAuth2::AccessToken do
51
51
  [:get, :delete, :post, :put].each do |method|
52
52
  describe method do
53
53
  it 'should delegate to HTTPClient with Authenticator filter' do
54
- token.httpclient.should_receive(method).with(resource_endpoint)
54
+ expect(token.httpclient).to receive(method).with(resource_endpoint)
55
55
  token.httpclient.request_filter.last.should be_a Rack::OAuth2::AccessToken::Authenticator
56
56
  token.send method, resource_endpoint
57
57
  end
@@ -12,7 +12,7 @@ describe Rack::OAuth2::Debugger::RequestFilter do
12
12
  "======= [Rack::OAuth2] HTTP REQUEST STARTED =======",
13
13
  request.dump
14
14
  ].each do |output|
15
- Rack::OAuth2.logger.should_receive(:info).with output
15
+ expect(Rack::OAuth2.logger).to receive(:info).with output
16
16
  end
17
17
  request_filter.filter_request(request)
18
18
  end
@@ -25,7 +25,7 @@ describe Rack::OAuth2::Debugger::RequestFilter do
25
25
  response.dump,
26
26
  "======= [Rack::OAuth2] HTTP REQUEST FINISHED ======="
27
27
  ].each do |output|
28
- Rack::OAuth2.logger.should_receive(:info).with output
28
+ expect(Rack::OAuth2.logger).to receive(:info).with output
29
29
  end
30
30
  request_filter.filter_response(request, response)
31
31
  end
@@ -5,27 +5,27 @@ describe Rack::OAuth2 do
5
5
  after { Rack::OAuth2.debugging = false }
6
6
 
7
7
  its(:logger) { should be_a Logger }
8
- its(:debugging?) { should be_false }
8
+ its(:debugging?) { should == false }
9
9
 
10
10
  describe '.debug!' do
11
11
  before { Rack::OAuth2.debug! }
12
- its(:debugging?) { should be_true }
12
+ its(:debugging?) { should == true }
13
13
  end
14
14
 
15
15
  describe '.debug' do
16
16
  it 'should enable debugging within given block' do
17
17
  Rack::OAuth2.debug do
18
- Rack::OAuth2.debugging?.should be_true
18
+ Rack::OAuth2.debugging?.should == true
19
19
  end
20
- Rack::OAuth2.debugging?.should be_false
20
+ Rack::OAuth2.debugging?.should == false
21
21
  end
22
22
 
23
23
  it 'should not force disable debugging' do
24
24
  Rack::OAuth2.debug!
25
25
  Rack::OAuth2.debug do
26
- Rack::OAuth2.debugging?.should be_true
26
+ Rack::OAuth2.debugging?.should == true
27
27
  end
28
- Rack::OAuth2.debugging?.should be_true
28
+ Rack::OAuth2.debugging?.should == true
29
29
  end
30
30
  end
31
31
 
@@ -33,7 +33,7 @@ describe Rack::OAuth2 do
33
33
  context 'when request_filter added' do
34
34
  context 'when "debug!" is called' do
35
35
  after { Rack::OAuth2.reset_http_config! }
36
-
36
+
37
37
  it 'should put Debugger::RequestFilter at last' do
38
38
  Rack::OAuth2.debug!
39
39
  Rack::OAuth2.http_config do |config|
@@ -73,24 +73,24 @@ describe Rack::OAuth2::Util do
73
73
  describe '.uri_match?' do
74
74
  context 'when invalid URI is given' do
75
75
  it do
76
- util.uri_match?('::', '::').should be_false
77
- util.uri_match?(123, 'http://client.example.com/other').should be_false
78
- util.uri_match?('http://client.example.com/other', nil).should be_false
76
+ util.uri_match?('::', '::').should == false
77
+ util.uri_match?(123, 'http://client.example.com/other').should == false
78
+ util.uri_match?('http://client.example.com/other', nil).should == false
79
79
  end
80
80
  end
81
81
 
82
82
  context 'when exactry same' do
83
- it { util.uri_match?(uri, uri).should be_true }
83
+ it { util.uri_match?(uri, uri).should == true }
84
84
  end
85
85
 
86
86
  context 'when path prefix matches' do
87
- it { util.uri_match?(uri, "#{uri}/deep_path").should be_true }
87
+ it { util.uri_match?(uri, "#{uri}/deep_path").should == true }
88
88
  end
89
89
 
90
90
  context 'otherwise' do
91
91
  it do
92
- util.uri_match?(uri, 'http://client.example.com/other').should be_false
93
- util.uri_match?(uri, 'http://attacker.example.com/callback').should be_false
92
+ util.uri_match?(uri, 'http://client.example.com/other').should == false
93
+ util.uri_match?(uri, 'http://attacker.example.com/callback').should == false
94
94
  end
95
95
  end
96
96
  end
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,15 @@ SimpleCov.start do
5
5
  end
6
6
 
7
7
  require 'rspec'
8
+ require 'rspec/its'
8
9
  require 'rack/oauth2'
10
+
11
+ RSpec.configure do |config|
12
+ config.expect_with :rspec do |c|
13
+ c.syntax = [:should, :expect]
14
+ end
15
+ end
16
+
9
17
  require 'helpers/time'
10
18
  require 'helpers/webmock_helper'
11
19
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-17 00:00:00.000000000 Z
11
+ date: 2014-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 2.2.0.2
47
+ version: '2.4'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 2.2.0.2
54
+ version: '2.4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -114,28 +114,42 @@ dependencies:
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: '2'
117
+ version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: '2'
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-its
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: webmock
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - ">="
130
144
  - !ruby/object:Gem::Version
131
- version: 1.6.2
145
+ version: '0'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - ">="
137
151
  - !ruby/object:Gem::Version
138
- version: 1.6.2
152
+ version: '0'
139
153
  description: OAuth 2.0 Server & Client Library. Both Bearer and MAC token type are
140
154
  supported.
141
155
  email: nov@matake.jp