rack-oauth2 1.21.1 → 1.21.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rack/oauth2/client.rb +1 -1
- data/spec/rack/oauth2/client_spec.rb +81 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bedb933d3946aef05d7ca583bd18b46941aebdf7fc0f8640be2f5909f9be4e9c
|
4
|
+
data.tar.gz: 8740a613173e5edd0c98d79d1079b933d3eaee89b56369ae109d10841d7b94d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 465ffccc2e5e41e396949947904f359a6d67d5637e6b0056a8bbca10f3b6755b14682fcad8092dddba7eabca72b66e1f66691b20a3351c79a7b1269abb478c07
|
7
|
+
data.tar.gz: c0b6d79ad4c019fa58034d446acaf7ee2d6ec5b9cf77e5b8548f924cbbc544e34d6c09d6a2433e9ed5dbca7915b27280602ce8a62dda12722a9b28a3c6c07bb8
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.21.
|
1
|
+
1.21.2
|
data/lib/rack/oauth2/client.rb
CHANGED
@@ -102,7 +102,7 @@ module Rack
|
|
102
102
|
token_type_hint: :refresh_token
|
103
103
|
}
|
104
104
|
when options[:token].blank?
|
105
|
-
raise
|
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
|