Sha256: e15366a5468d323884535305c5d6a889b612e3eeb00bcf90a7d60689e36d22ef

Contents?: true

Size: 1.11 KB

Versions: 18

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module G5Authenticatable
  module Test
    # Helpers for stubbing token validation requests
    module TokenValidationHelpers
      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

      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
    end
  end
end

RSpec.configure do |config|
  config.include G5Authenticatable::Test::TokenValidationHelpers
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
g5_authenticatable-1.1.4 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.1.4.rc.3 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.1.4.rc.2 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.1.4.rc.1 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.1.2 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.1.2.pre.1 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.1.2.rc.5 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.1.2.rc.4 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.1.2.rc.3 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.1.2.rc.2 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.1.2.rc.1 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.1.1 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.1.0 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.0.0 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.0.0.pre.4 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.0.0.pre.3 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.0.0.pre.2 lib/g5_authenticatable/test/token_validation_helpers.rb
g5_authenticatable-1.0.0.pre.1 lib/g5_authenticatable/test/token_validation_helpers.rb