|
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 | 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
|
0 commit comments