-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
175 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
module Auth0 | ||
module Api | ||
module V2 | ||
# Methods to use the Refresh Token endpoints | ||
module RefreshTokens | ||
# Retrieve refresh token information. | ||
# @see https://auth0.com/docs/api/management/v2/refresh-tokens/get-refresh-token | ||
# @param id [string] The id of the refresh token to retrieve | ||
def refresh_token(id) | ||
raise Auth0::InvalidParameter, 'Must supply a valid id' if id.to_s.empty? | ||
|
||
get "#{resource_path}/#{id}" | ||
end | ||
|
||
# Delete a refresh token by its ID. | ||
# @see https://auth0.com/docs/api/management/v2/refresh-tokens/delete-refresh-token | ||
# @param id [string] The id of the refresh token to delete | ||
def delete_refresh_token(id) | ||
raise Auth0::InvalidParameter, 'Must supply a valid id' if id.to_s.empty? | ||
|
||
delete "#{resource_path}/#{id}" | ||
end | ||
|
||
private | ||
|
||
def resource_path | ||
@resource_path ||= '/api/v2/refresh-tokens' | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe Auth0::Api::V2::RefreshTokens do | ||
before :all do | ||
dummy_instance = DummyClass.new | ||
dummy_instance.extend(Auth0::Api::V2::RefreshTokens) | ||
@instance = dummy_instance | ||
end | ||
|
||
describe '.refresh_token' do | ||
it 'is expected to respond to a refresh_token method' do | ||
expect(@instance).to respond_to(:refresh_token) | ||
end | ||
|
||
it 'is expected to GET a refresh_token' do | ||
expect(@instance).to receive(:get).with( | ||
'/api/v2/refresh-tokens/REFRESH_TOKEN_ID' | ||
) | ||
|
||
expect do | ||
@instance.refresh_token('REFRESH_TOKEN_ID') | ||
end.not_to raise_error | ||
end | ||
|
||
it 'is expected to raise an exception when the id is empty' do | ||
expect { @instance.refresh_token(nil) }.to raise_error('Must supply a valid id') | ||
end | ||
end | ||
|
||
describe '.delete_refresh_token' do | ||
it 'is expected to respond to a delete_refresh_token method' do | ||
expect(@instance).to respond_to(:delete_refresh_token) | ||
end | ||
|
||
it 'is expected to DELETE a refresh_token' do | ||
expect(@instance).to receive(:delete).with( | ||
'/api/v2/refresh-tokens/REFRESH_TOKEN_ID' | ||
) | ||
|
||
expect do | ||
@instance.delete_refresh_token('REFRESH_TOKEN_ID') | ||
end.not_to raise_error | ||
end | ||
|
||
it 'is expected to raise an exception when the id is empty' do | ||
expect { @instance.delete_refresh_token(nil) }.to raise_error('Must supply a valid id') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters