Sha256: 716928d2c4923cd7e81eb806cd4971c7ec82200d54969c6fb190cbd0e34388b7

Contents?: true

Size: 888 Bytes

Versions: 12

Compression:

Stored size: 888 Bytes

Contents

module SignKeyFixtureHelper
  def shared_secret
    'shared-secret'
  end

  def pem_file(file_name)
    File.new(
      File.join(
        File.dirname(__FILE__),
        "../fixtures/#{file_name}.pem"
      )
    )
  end

  def private_key(algorithm = :rsa, options = {})
    case algorithm
    when :rsa
      OpenSSL::PKey::RSA.new(
        pem_file("#{algorithm}/private_key"),
        'pass-phrase'
      )
    when :ecdsa
      OpenSSL::PKey::EC.new(
        pem_file("#{algorithm}/#{options[:digest_length]}/private_key")
      )
    end
  end

  def public_key(algorithm = :rsa, options = {})
    case algorithm
    when :rsa
      OpenSSL::PKey::RSA.new(
        pem_file("#{algorithm}/public_key")
      )
    when :ecdsa
      OpenSSL::PKey::EC.new(
        pem_file("#{algorithm}/#{options[:digest_length]}/public_key")
      )
    end
  end
end

include SignKeyFixtureHelper

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
json-jwt-0.4.3 spec/helpers/sign_key_fixture_helper.rb
json-jwt-0.4.2 spec/helpers/sign_key_fixture_helper.rb
json-jwt-0.4.1 spec/helpers/sign_key_fixture_helper.rb
json-jwt-0.4.0 spec/helpers/sign_key_fixture_helper.rb
json-jwt-0.3.3 spec/helpers/sign_key_fixture_helper.rb
json-jwt-0.3.2 spec/helpers/sign_key_fixture_helper.rb
json-jwt-0.3.1 spec/helpers/sign_key_fixture_helper.rb
json-jwt-0.3.0 spec/helpers/sign_key_fixture_helper.rb
json-jwt-0.2.0 spec/helpers/sign_key_fixture_helper.rb
json-jwt-0.1.8 spec/helpers/sign_key_fixture_helper.rb
json-jwt-0.1.7 spec/helpers/sign_key_fixture_helper.rb
json-jwt-0.1.6 spec/helpers/sign_key_fixture_helper.rb