oauth2 1.4.4 → 1.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -2
  3. data/CODE_OF_CONDUCT.md +105 -46
  4. data/README.md +8 -3
  5. data/lib/oauth2/access_token.rb +8 -7
  6. data/lib/oauth2/authenticator.rb +1 -1
  7. data/lib/oauth2/client.rb +60 -14
  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 +38 -41
  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 -87
  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_2.7.gemfile +0 -9
  53. data/gemfiles/ruby_head.gemfile +0 -9
  54. data/gemfiles/truffleruby.gemfile +0 -3
  55. data/oauth2.gemspec +0 -52
@@ -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.4
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: 2020-02-13 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,38 +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_2.7.gemfile
315
- - gemfiles/ruby_head.gemfile
316
- - gemfiles/truffleruby.gemfile
317
289
  - lib/oauth2.rb
318
290
  - lib/oauth2/access_token.rb
319
291
  - lib/oauth2/authenticator.rb
@@ -328,17 +300,29 @@ files:
328
300
  - lib/oauth2/strategy/implicit.rb
329
301
  - lib/oauth2/strategy/password.rb
330
302
  - lib/oauth2/version.rb
331
- - 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
332
316
  homepage: https://github.com/oauth-xx/oauth2
333
317
  licenses:
334
318
  - MIT
335
319
  metadata:
336
320
  bug_tracker_uri: https://github.com/oauth-xx/oauth2/issues
337
- changelog_uri: https://github.com/oauth-xx/oauth2/blob/v1.4.4/CHANGELOG.md
338
- documentation_uri: https://www.rubydoc.info/gems/oauth2/1.4.4
339
- source_code_uri: https://github.com/oauth-xx/oauth2/tree/v1.4.4
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
340
324
  wiki_uri: https://github.com/oauth-xx/oauth2/wiki
341
- post_install_message:
325
+ post_install_message:
342
326
  rdoc_options: []
343
327
  require_paths:
344
328
  - lib
@@ -353,8 +337,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
353
337
  - !ruby/object:Gem::Version
354
338
  version: 1.3.5
355
339
  requirements: []
356
- rubygems_version: 3.1.2
357
- signing_key:
340
+ rubygems_version: 3.2.9
341
+ signing_key:
358
342
  specification_version: 4
359
343
  summary: A Ruby wrapper for the OAuth 2.0 protocol.
360
- 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.7.0
data/.travis.yml DELETED
@@ -1,87 +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
- before_script:
23
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
24
- - chmod +x ./cc-test-reporter
25
- - ./cc-test-reporter before-build
26
-
27
- after_script:
28
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
29
-
30
- bundler_args: --no-deployment --jobs 3 --retry 3
31
-
32
- cache: bundler
33
-
34
- env:
35
- global:
36
- - JRUBY_OPTS="$JRUBY_OPTS -Xcli.debug=true --debug"
37
- - CC_TEST_REPORTER_ID=29caf9cf27d27ae609c088feb9d4ba34460f7a39251f2e8615c9a16f3075530e
38
-
39
- language: ruby
40
-
41
- matrix:
42
- allow_failures:
43
- - rvm: jruby-head
44
- - rvm: ruby-head
45
- - rvm: truffleruby
46
- - rvm: jruby-9.0
47
- - rvm: jruby-9.1 # jruby-9.1 often fails to download, thus failing the build.
48
- - rvm: jruby-9.2 # jruby-9.2 often fails to download, thus failing the build.
49
- fast_finish: true
50
- include:
51
- # - rvm: jruby-1.7 # targets MRI v1.9
52
- # gemfile: gemfiles/jruby_1.7.gemfile
53
- - rvm: 1.9
54
- gemfile: gemfiles/ruby_1.9.gemfile
55
- - rvm: 2.0
56
- gemfile: gemfiles/ruby_2.0.gemfile
57
- - rvm: jruby-9.0 # targets MRI v2.0
58
- gemfile: gemfiles/jruby_9.0.gemfile
59
- - rvm: 2.1
60
- gemfile: gemfiles/ruby_2.1.gemfile
61
- # DEPRECATION WARNING
62
- # oauth2 1.x series releases are the last to support Ruby versions above
63
- # oauth2 2.x series releases will support Ruby versions below, and not above
64
- - rvm: jruby-9.1 # targets MRI v2.3
65
- gemfile: gemfiles/jruby_9.1.gemfile
66
- - rvm: 2.2
67
- gemfile: gemfiles/ruby_2.2.gemfile
68
- - rvm: 2.3
69
- gemfile: gemfiles/ruby_2.3.gemfile
70
- - rvm: 2.4
71
- gemfile: gemfiles/ruby_2.4.gemfile
72
- - rvm: jruby-9.2 # targets MRI v2.5
73
- gemfile: gemfiles/jruby_9.2.gemfile
74
- - rvm: 2.5
75
- gemfile: gemfiles/ruby_2.5.gemfile
76
- - rvm: 2.6
77
- gemfile: gemfiles/ruby_2.6.gemfile
78
- - rvm: 2.7
79
- gemfile: gemfiles/ruby_2.7.gemfile
80
- - rvm: jruby-head
81
- gemfile: gemfiles/jruby_head.gemfile
82
- - rvm: ruby-head
83
- gemfile: gemfiles/ruby_head.gemfile
84
- - rvm: truffleruby
85
- gemfile: gemfiles/truffleruby.gemfile
86
-
87
- sudo: false