oauth2 1.4.2 → 1.4.7

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -2
  3. data/CODE_OF_CONDUCT.md +105 -46
  4. data/README.md +33 -5
  5. data/lib/oauth2/access_token.rb +12 -4
  6. data/lib/oauth2/authenticator.rb +10 -0
  7. data/lib/oauth2/client.rb +63 -16
  8. data/lib/oauth2/mac_token.rb +10 -2
  9. data/lib/oauth2/response.rb +5 -3
  10. data/lib/oauth2/strategy/assertion.rb +3 -3
  11. data/lib/oauth2/strategy/password.rb +2 -2
  12. data/lib/oauth2/version.rb +9 -3
  13. data/spec/helper.rb +37 -0
  14. data/spec/oauth2/access_token_spec.rb +216 -0
  15. data/spec/oauth2/authenticator_spec.rb +84 -0
  16. data/spec/oauth2/client_spec.rb +506 -0
  17. data/spec/oauth2/mac_token_spec.rb +117 -0
  18. data/spec/oauth2/response_spec.rb +90 -0
  19. data/spec/oauth2/strategy/assertion_spec.rb +58 -0
  20. data/spec/oauth2/strategy/auth_code_spec.rb +107 -0
  21. data/spec/oauth2/strategy/base_spec.rb +5 -0
  22. data/spec/oauth2/strategy/client_credentials_spec.rb +69 -0
  23. data/spec/oauth2/strategy/implicit_spec.rb +26 -0
  24. data/spec/oauth2/strategy/password_spec.rb +55 -0
  25. data/spec/oauth2/version_spec.rb +23 -0
  26. metadata +41 -38
  27. data/.document +0 -5
  28. data/.gitignore +0 -19
  29. data/.jrubyrc +0 -1
  30. data/.rspec +0 -2
  31. data/.rubocop.yml +0 -80
  32. data/.rubocop_rspec.yml +0 -26
  33. data/.rubocop_todo.yml +0 -15
  34. data/.ruby-version +0 -1
  35. data/.travis.yml +0 -70
  36. data/CONTRIBUTING.md +0 -18
  37. data/Gemfile +0 -40
  38. data/Rakefile +0 -45
  39. data/gemfiles/jruby_1.7.gemfile +0 -11
  40. data/gemfiles/jruby_9.0.gemfile +0 -7
  41. data/gemfiles/jruby_9.1.gemfile +0 -3
  42. data/gemfiles/jruby_9.2.gemfile +0 -3
  43. data/gemfiles/jruby_head.gemfile +0 -3
  44. data/gemfiles/ruby_1.9.gemfile +0 -11
  45. data/gemfiles/ruby_2.0.gemfile +0 -6
  46. data/gemfiles/ruby_2.1.gemfile +0 -6
  47. data/gemfiles/ruby_2.2.gemfile +0 -3
  48. data/gemfiles/ruby_2.3.gemfile +0 -3
  49. data/gemfiles/ruby_2.4.gemfile +0 -3
  50. data/gemfiles/ruby_2.5.gemfile +0 -3
  51. data/gemfiles/ruby_2.6.gemfile +0 -9
  52. data/gemfiles/ruby_head.gemfile +0 -9
  53. data/gemfiles/truffleruby.gemfile +0 -3
  54. data/oauth2.gemspec +0 -44
@@ -0,0 +1,26 @@
1
+ describe OAuth2::Strategy::Implicit do
2
+ subject { client.implicit }
3
+
4
+ let(:client) { OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com') }
5
+
6
+ describe '#authorize_url' do
7
+ it 'includes the client_id' do
8
+ expect(subject.authorize_url).to include('client_id=abc')
9
+ end
10
+
11
+ it 'includes the type' do
12
+ expect(subject.authorize_url).to include('response_type=token')
13
+ end
14
+
15
+ it 'includes passed in options' do
16
+ cb = 'http://myserver.local/oauth/callback'
17
+ expect(subject.authorize_url(:redirect_uri => cb)).to include("redirect_uri=#{Rack::Utils.escape(cb)}")
18
+ end
19
+ end
20
+
21
+ describe '#get_token' do
22
+ it 'raises NotImplementedError' do
23
+ expect { subject.get_token }.to raise_error(NotImplementedError)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,55 @@
1
+ describe OAuth2::Strategy::Password do
2
+ subject { client.password }
3
+
4
+ let(:client) do
5
+ cli = OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com')
6
+ cli.connection.build do |b|
7
+ b.adapter :test do |stub|
8
+ stub.post('/oauth/token') do |env|
9
+ case @mode
10
+ when 'formencoded'
11
+ [200, {'Content-Type' => 'application/x-www-form-urlencoded'}, 'expires_in=600&access_token=salmon&refresh_token=trout']
12
+ when 'json'
13
+ [200, {'Content-Type' => 'application/json'}, '{"expires_in":600,"access_token":"salmon","refresh_token":"trout"}']
14
+ end
15
+ end
16
+ end
17
+ end
18
+ cli
19
+ end
20
+
21
+ describe '#authorize_url' do
22
+ it 'raises NotImplementedError' do
23
+ expect { subject.authorize_url }.to raise_error(NotImplementedError)
24
+ end
25
+ end
26
+
27
+ %w[json formencoded].each do |mode|
28
+ describe "#get_token (#{mode})" do
29
+ before do
30
+ @mode = mode
31
+ @access = subject.get_token('username', 'password')
32
+ end
33
+
34
+ it 'returns AccessToken with same Client' do
35
+ expect(@access.client).to eq(client)
36
+ end
37
+
38
+ it 'returns AccessToken with #token' do
39
+ expect(@access.token).to eq('salmon')
40
+ end
41
+
42
+ it 'returns AccessToken with #refresh_token' do
43
+ expect(@access.refresh_token).to eq('trout')
44
+ end
45
+
46
+ it 'returns AccessToken with #expires_in' do
47
+ expect(@access.expires_in).to eq(600)
48
+ end
49
+
50
+ it 'returns AccessToken with #expires_at' do
51
+ expect(@access.expires_at).not_to be_nil
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe OAuth2::Version do
4
+ it 'has a version number' do
5
+ expect(described_class).not_to be nil
6
+ end
7
+
8
+ it 'can be a string' do
9
+ expect(described_class.to_s).to be_a(String)
10
+ end
11
+
12
+ it 'allows Constant access' do
13
+ expect(described_class::VERSION).to be_a(String)
14
+ end
15
+
16
+ it 'is greater than 0.1.0' do
17
+ expect(Gem::Version.new(described_class) > Gem::Version.new('0.1.0')).to be(true)
18
+ end
19
+
20
+ it 'is not a pre-release' do
21
+ expect(Gem::Version.new(described_class).prerelease?).to be(false)
22
+ end
23
+ end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
8
8
  - Michael Bleigh
9
9
  - Erik Michaels-Ober
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2019-10-01 00:00:00.000000000 Z
13
+ date: 2021-03-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -205,7 +205,7 @@ dependencies:
205
205
  - !ruby/object:Gem::Version
206
206
  version: '3.0'
207
207
  - !ruby/object:Gem::Dependency
208
- name: rspec-stubbed_env
208
+ name: rspec-block_is_expected
209
209
  requirement: !ruby/object:Gem::Requirement
210
210
  requirements:
211
211
  - - ">="
@@ -233,7 +233,7 @@ dependencies:
233
233
  - !ruby/object:Gem::Version
234
234
  version: '0'
235
235
  - !ruby/object:Gem::Dependency
236
- name: rspec-block_is_expected
236
+ name: rspec-stubbed_env
237
237
  requirement: !ruby/object:Gem::Requirement
238
238
  requirements:
239
239
  - - ">="
@@ -282,37 +282,10 @@ executables: []
282
282
  extensions: []
283
283
  extra_rdoc_files: []
284
284
  files:
285
- - ".document"
286
- - ".gitignore"
287
- - ".jrubyrc"
288
- - ".rspec"
289
- - ".rubocop.yml"
290
- - ".rubocop_rspec.yml"
291
- - ".rubocop_todo.yml"
292
- - ".ruby-version"
293
- - ".travis.yml"
294
285
  - CHANGELOG.md
295
286
  - CODE_OF_CONDUCT.md
296
- - CONTRIBUTING.md
297
- - Gemfile
298
287
  - LICENSE
299
288
  - README.md
300
- - Rakefile
301
- - gemfiles/jruby_1.7.gemfile
302
- - gemfiles/jruby_9.0.gemfile
303
- - gemfiles/jruby_9.1.gemfile
304
- - gemfiles/jruby_9.2.gemfile
305
- - gemfiles/jruby_head.gemfile
306
- - gemfiles/ruby_1.9.gemfile
307
- - gemfiles/ruby_2.0.gemfile
308
- - gemfiles/ruby_2.1.gemfile
309
- - gemfiles/ruby_2.2.gemfile
310
- - gemfiles/ruby_2.3.gemfile
311
- - gemfiles/ruby_2.4.gemfile
312
- - gemfiles/ruby_2.5.gemfile
313
- - gemfiles/ruby_2.6.gemfile
314
- - gemfiles/ruby_head.gemfile
315
- - gemfiles/truffleruby.gemfile
316
289
  - lib/oauth2.rb
317
290
  - lib/oauth2/access_token.rb
318
291
  - lib/oauth2/authenticator.rb
@@ -327,12 +300,29 @@ files:
327
300
  - lib/oauth2/strategy/implicit.rb
328
301
  - lib/oauth2/strategy/password.rb
329
302
  - lib/oauth2/version.rb
330
- - oauth2.gemspec
303
+ - spec/helper.rb
304
+ - spec/oauth2/access_token_spec.rb
305
+ - spec/oauth2/authenticator_spec.rb
306
+ - spec/oauth2/client_spec.rb
307
+ - spec/oauth2/mac_token_spec.rb
308
+ - spec/oauth2/response_spec.rb
309
+ - spec/oauth2/strategy/assertion_spec.rb
310
+ - spec/oauth2/strategy/auth_code_spec.rb
311
+ - spec/oauth2/strategy/base_spec.rb
312
+ - spec/oauth2/strategy/client_credentials_spec.rb
313
+ - spec/oauth2/strategy/implicit_spec.rb
314
+ - spec/oauth2/strategy/password_spec.rb
315
+ - spec/oauth2/version_spec.rb
331
316
  homepage: https://github.com/oauth-xx/oauth2
332
317
  licenses:
333
318
  - MIT
334
- metadata: {}
335
- post_install_message:
319
+ metadata:
320
+ bug_tracker_uri: https://github.com/oauth-xx/oauth2/issues
321
+ changelog_uri: https://github.com/oauth-xx/oauth2/blob/v1.4.7/CHANGELOG.md
322
+ documentation_uri: https://www.rubydoc.info/gems/oauth2/1.4.7
323
+ source_code_uri: https://github.com/oauth-xx/oauth2/tree/v1.4.7
324
+ wiki_uri: https://github.com/oauth-xx/oauth2/wiki
325
+ post_install_message:
336
326
  rdoc_options: []
337
327
  require_paths:
338
328
  - lib
@@ -347,8 +337,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
347
337
  - !ruby/object:Gem::Version
348
338
  version: 1.3.5
349
339
  requirements: []
350
- rubygems_version: 3.0.3
351
- signing_key:
340
+ rubygems_version: 3.2.9
341
+ signing_key:
352
342
  specification_version: 4
353
343
  summary: A Ruby wrapper for the OAuth 2.0 protocol.
354
- test_files: []
344
+ test_files:
345
+ - spec/helper.rb
346
+ - spec/oauth2/client_spec.rb
347
+ - spec/oauth2/version_spec.rb
348
+ - spec/oauth2/authenticator_spec.rb
349
+ - spec/oauth2/mac_token_spec.rb
350
+ - spec/oauth2/access_token_spec.rb
351
+ - spec/oauth2/response_spec.rb
352
+ - spec/oauth2/strategy/password_spec.rb
353
+ - spec/oauth2/strategy/client_credentials_spec.rb
354
+ - spec/oauth2/strategy/assertion_spec.rb
355
+ - spec/oauth2/strategy/implicit_spec.rb
356
+ - spec/oauth2/strategy/auth_code_spec.rb
357
+ - spec/oauth2/strategy/base_spec.rb
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,19 +0,0 @@
1
- *.gem
2
- *~
3
- .bundle
4
- .rvmrc
5
- Gemfile.lock
6
- coverage/*
7
- log/*
8
- measurement/*
9
- pkg/*
10
- rdoc/*
11
-
12
- # rspec failure tracking
13
- .rspec_status
14
-
15
- # gemfiles for CI
16
- /gemfiles/*.gemfile.lock
17
-
18
- # CI bundle
19
- /gemfiles/vendor/
data/.jrubyrc DELETED
@@ -1 +0,0 @@
1
- debug.fullTrace=true
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --order random
data/.rubocop.yml DELETED
@@ -1,80 +0,0 @@
1
- require: rubocop-rspec
2
- inherit_from:
3
- - .rubocop_todo.yml
4
- - .rubocop_rspec.yml
5
- AllCops:
6
- DisplayCopNames: true # Display the name of the failing cops
7
- TargetRubyVersion: 2.1
8
- Exclude:
9
- - 'gemfiles/vendor/**/*'
10
- - 'vendor/**/*'
11
- - '**/.irbrc'
12
-
13
- Gemspec/RequiredRubyVersion:
14
- Enabled: false
15
-
16
- Metrics/BlockLength:
17
- Enabled: false
18
-
19
- Metrics/BlockNesting:
20
- Max: 2
21
-
22
- Metrics/LineLength:
23
- Enabled: false
24
-
25
- Metrics/MethodLength:
26
- Max: 15
27
-
28
- Metrics/ParameterLists:
29
- Max: 4
30
-
31
- Layout/AccessModifierIndentation:
32
- EnforcedStyle: outdent
33
-
34
- Layout/DotPosition:
35
- EnforcedStyle: trailing
36
-
37
- Layout/SpaceInsideHashLiteralBraces:
38
- EnforcedStyle: no_space
39
-
40
- Lint/UnusedBlockArgument:
41
- Exclude:
42
- - 'spec/**/*.rb'
43
- - 'gemfiles/vendor/**/*'
44
- - 'vendor/**/*'
45
- - '**/.irbrc'
46
-
47
- RSpec/DescribeClass:
48
- Exclude:
49
- - 'spec/examples/*'
50
-
51
- RSpec/NestedGroups:
52
- Enabled: false
53
-
54
- Style/ClassVars:
55
- Enabled: false
56
-
57
- Style/CollectionMethods:
58
- PreferredMethods:
59
- map: 'collect'
60
- reduce: 'inject'
61
- find: 'detect'
62
- find_all: 'select'
63
-
64
- Style/Documentation:
65
- Enabled: false
66
-
67
- Style/DoubleNegation:
68
- Enabled: false
69
-
70
- Style/EmptyMethod:
71
- EnforcedStyle: expanded
72
-
73
- Style/Encoding:
74
- Enabled: false
75
-
76
- Style/TrailingCommaInArrayLiteral:
77
- EnforcedStyleForMultiline: comma
78
-
79
- Style/TrailingCommaInHashLiteral:
80
- EnforcedStyleForMultiline: comma
data/.rubocop_rspec.yml DELETED
@@ -1,26 +0,0 @@
1
- RSpec/FilePath:
2
- Enabled: false
3
-
4
- RSpec/MultipleExpectations:
5
- Enabled: false
6
-
7
- RSpec/NamedSubject:
8
- Enabled: false
9
-
10
- RSpec/ExampleLength:
11
- Enabled: false
12
-
13
- RSpec/VerifiedDoubles:
14
- Enabled: false
15
-
16
- RSpec/MessageSpies:
17
- Enabled: false
18
-
19
- RSpec/InstanceVariable:
20
- Enabled: false
21
-
22
- RSpec/NestedGroups:
23
- Enabled: false
24
-
25
- RSpec/ExpectInHook:
26
- Enabled: false
data/.rubocop_todo.yml DELETED
@@ -1,15 +0,0 @@
1
- Style/HashSyntax:
2
- EnforcedStyle: hash_rockets
3
-
4
- Style/Lambda:
5
- Enabled: false
6
-
7
- Style/SymbolArray:
8
- Enabled: false
9
-
10
- Style/EachWithObject:
11
- Enabled: false
12
-
13
- # Once we drop Rubies that lack support for __dir__ we can turn this on.
14
- Style/ExpandPathArguments:
15
- Enabled: false
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.6.3
data/.travis.yml DELETED
@@ -1,70 +0,0 @@
1
- before_install:
2
- # rubygems 2.7.8 and greater include bundler
3
- # - Ruby 2.2, and under, get RubyGems ~> 2.7.10, (includes bundler 1.17.3)
4
- # - Anything else, including Ruby 2.3, and above, gets RubyGems ~> 3, and update bundler to latest
5
- # - NOTE ON JRUBY: identifies as RUBY_VERSION ~> 1.9, 2.0, 2.3, or 2.5.
6
- # - NOTE ON TRUFFLERUBY: identifies as RUBY_VERSION ~> 2.6
7
- - |
8
- rv="$(ruby -e 'STDOUT.write RUBY_VERSION')"
9
- echo "Discovered Ruby Version of =====> $rv"
10
- if [ "$rv" \< "2.3" ]; then
11
- gem update --system 2.7.10
12
- elif [ "$rv" \< "2.4" ]; then
13
- gem update --system 2.7.10 --no-document
14
- elif [ "$rv" = "2.5.3" ]; then
15
- # JRUBY 9.2 Identifies as 2.5.3, and it fails to update rubygems
16
- gem install --no-document bundler "bundler:>=2.0"
17
- else
18
- gem update --system --no-document --conservative
19
- gem install --no-document bundler "bundler:>=2.0"
20
- fi
21
-
22
- bundler_args: --no-deployment --jobs 3 --retry 3
23
-
24
- cache: bundler
25
-
26
- language: ruby
27
-
28
- matrix:
29
- allow_failures:
30
- - rvm: jruby-head
31
- - rvm: ruby-head
32
- - rvm: truffleruby
33
- - rvm: jruby-9.0
34
- fast_finish: true
35
- include:
36
- # - rvm: jruby-1.7 # targets MRI v1.9
37
- # gemfile: gemfiles/jruby_1.7.gemfile
38
- - rvm: 1.9
39
- gemfile: gemfiles/ruby_1.9.gemfile
40
- - rvm: 2.0
41
- gemfile: gemfiles/ruby_2.0.gemfile
42
- - rvm: jruby-9.0 # targets MRI v2.0
43
- gemfile: gemfiles/jruby_9.0.gemfile
44
- - rvm: 2.1
45
- gemfile: gemfiles/ruby_2.1.gemfile
46
- # DEPRECATION WARNING
47
- # oauth2 1.x series releases are the last to support Ruby versions above
48
- # oauth2 2.x series releases will support Ruby versions below, and not above
49
- - rvm: jruby-9.1 # targets MRI v2.3
50
- gemfile: gemfiles/jruby_9.1.gemfile
51
- - rvm: 2.2
52
- gemfile: gemfiles/ruby_2.2.gemfile
53
- - rvm: 2.3
54
- gemfile: gemfiles/ruby_2.3.gemfile
55
- - rvm: 2.4
56
- gemfile: gemfiles/ruby_2.4.gemfile
57
- - rvm: jruby-9.2 # targets MRI v2.5
58
- gemfile: gemfiles/jruby_9.2.gemfile
59
- - rvm: 2.5
60
- gemfile: gemfiles/ruby_2.5.gemfile
61
- - rvm: 2.6
62
- gemfile: gemfiles/ruby_2.6.gemfile
63
- - rvm: jruby-head
64
- gemfile: gemfiles/jruby_head.gemfile
65
- - rvm: ruby-head
66
- gemfile: gemfiles/ruby_head.gemfile
67
- - rvm: truffleruby
68
- gemfile: gemfiles/truffleruby.gemfile
69
-
70
- sudo: false