rack-oauth2 1.21.1 → 1.21.2

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
  SHA256:
3
- metadata.gz: 17e0edf7d39ad95a4edf13dfa1ca296b4ac1d3841076bb64adda5accabf2b1d1
4
- data.tar.gz: 492457b7b803713f3111b0362127a5a5a16fe05c6183c855f639a81295c8b340
3
+ metadata.gz: bedb933d3946aef05d7ca583bd18b46941aebdf7fc0f8640be2f5909f9be4e9c
4
+ data.tar.gz: 8740a613173e5edd0c98d79d1079b933d3eaee89b56369ae109d10841d7b94d8
5
5
  SHA512:
6
- metadata.gz: e5cdcab32150362bd135154fe3f1d276db1671e0f75cd11f959919d002aaadcb44e4a07d847c63067b4c90477e0643d5fb07c6ad2ece1ba7596d6fc418f3d67e
7
- data.tar.gz: a4982720cf5c19437bbc3ec97687c6a77c0af9254a1ee8fd315bc0cb47202d0e1c41bba56691c49c0c609f42d51dbbd8da1cec54117d7c9b5c419c8c2ae048be
6
+ metadata.gz: 465ffccc2e5e41e396949947904f359a6d67d5637e6b0056a8bbca10f3b6755b14682fcad8092dddba7eabca72b66e1f66691b20a3351c79a7b1269abb478c07
7
+ data.tar.gz: c0b6d79ad4c019fa58034d446acaf7ee2d6ec5b9cf77e5b8548f924cbbc544e34d6c09d6a2433e9ed5dbca7915b27280602ce8a62dda12722a9b28a3c6c07bb8
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.21.1
1
+ 1.21.2
@@ -102,7 +102,7 @@ module Rack
102
102
  token_type_hint: :refresh_token
103
103
  }
104
104
  when options[:token].blank?
105
- raise AttrRequired::AttrMissing, 'One of "token", "access_token" and "refresh_token" is required'
105
+ raise ArgumentError, 'One of "token", "access_token" and "refresh_token" is required'
106
106
  end
107
107
  params.merge! options
108
108
 
@@ -448,12 +448,86 @@ describe Rack::OAuth2::Client do
448
448
  end
449
449
  end
450
450
 
451
+ describe '#revoke!' do
452
+ context 'when access_token given' do
453
+ before do
454
+ mock_response(
455
+ :post,
456
+ 'https://server.example.com/oauth2/revoke',
457
+ 'blank',
458
+ status: 200,
459
+ body: {
460
+ token: 'access_token',
461
+ token_type_hint: 'access_token'
462
+ }
463
+ )
464
+ end
465
+ it do
466
+ client.revoke!(access_token: 'access_token').should == :success
467
+ end
468
+ end
469
+
470
+ context 'when refresh_token given' do
471
+ before do
472
+ mock_response(
473
+ :post,
474
+ 'https://server.example.com/oauth2/revoke',
475
+ 'blank',
476
+ status: 200,
477
+ body: {
478
+ token: 'refresh_token',
479
+ token_type_hint: 'refresh_token'
480
+ }
481
+ )
482
+ end
483
+
484
+ context 'as argument' do
485
+ it do
486
+ client.revoke!(refresh_token: 'refresh_token').should == :success
487
+ end
488
+ end
489
+
490
+ context 'as grant' do
491
+ it do
492
+ client.refresh_token = 'refresh_token'
493
+ client.revoke!
494
+ end
495
+ end
496
+ end
497
+
498
+ context 'when error response given' do
499
+ before do
500
+ mock_response(
501
+ :post,
502
+ 'https://server.example.com/oauth2/revoke',
503
+ 'errors/invalid_request.json',
504
+ status: 400
505
+ )
506
+ end
507
+
508
+ it do
509
+ expect do
510
+ client.revoke! access_token: 'access_token'
511
+ end.to raise_error Rack::OAuth2::Client::Error
512
+ end
513
+ end
514
+
515
+ context 'when no token given' do
516
+ it do
517
+ expect do
518
+ client.revoke!
519
+ end.to raise_error ArgumentError
520
+ end
521
+ end
522
+ end
523
+
451
524
  context 'when no host info' do
452
525
  let :client do
453
526
  Rack::OAuth2::Client.new(
454
527
  identifier: 'client_id',
455
528
  secret: 'client_secret',
456
- redirect_uri: 'https://client.example.com/callback'
529
+ redirect_uri: 'https://client.example.com/callback',
530
+ revocation_endpoint: '/oauth2/revoke'
457
531
  )
458
532
  end
459
533
 
@@ -468,5 +542,11 @@ describe Rack::OAuth2::Client do
468
542
  expect { client.access_token! }.to raise_error 'No Host Info'
469
543
  end
470
544
  end
545
+
546
+ describe '#revoke!' do
547
+ it do
548
+ expect { client.revoke! access_token: 'access_token' }.to raise_error 'No Host Info'
549
+ end
550
+ end
471
551
  end
472
552
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.1
4
+ version: 1.21.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake