module G5Authenticatable::Test::TokenValidationHelpers

Helpers for stubbing token validation requests

Public Instance Methods

stub_invalid_access_token(token_value) click to toggle source
# File lib/g5_authenticatable/test/token_validation_helpers.rb, line 13
def stub_invalid_access_token(token_value)
  stub_request(:get, "#{ENV['G5_AUTH_ENDPOINT']}/oauth/token/info")
    .with(headers: { 'Authorization' => "Bearer #{token_value}" })
    .to_return(status: 401,
               headers: { 'Content-Type' => 'application/json;' \
                          ' charset=utf-8',
                          'Cache-Control' => 'no-cache' },
               body: { 'error' => 'invalid_token',
                       'error_description' => 'The access token expired' }
                     .to_json)
end
stub_valid_access_token(token_value) click to toggle source
# File lib/g5_authenticatable/test/token_validation_helpers.rb, line 7
def stub_valid_access_token(token_value)
  stub_request(:get, "#{ENV['G5_AUTH_ENDPOINT']}/oauth/token/info")
    .with(headers: { 'Authorization' => "Bearer #{token_value}" })
    .to_return(status: 200, body: '', headers: {})
end