Sha256: 6e1cf1810c4debd5a40ba34638a76572728cb9fa4659b38bea35fb2bc770683a

Contents?: true

Size: 714 Bytes

Versions: 3

Compression:

Stored size: 714 Bytes

Contents

require 'spec_helper'

describe JSON::JWK do
  let(:rsa_public_key) { public_key }

  context 'when RSA public key given' do
    let(:jwk) { JSON::JWK.new rsa_public_key }
    it { jwk.should include :alg, :exp, :mod }
    its(:alg) { jwk[:alg].should == :RSA }
    its(:exp) { jwk[:exp].should == UrlSafeBase64.encode64(rsa_public_key.e.to_s(2)) }
    its(:mod) { jwk[:mod].should == UrlSafeBase64.encode64(rsa_public_key.n.to_s(2)) }

    context 'when kid/use options given' do
      let(:jwk) { JSON::JWK.new rsa_public_key, :kid => '12345', :use => :sig }
      it { jwk.should include :kid, :use }
      its(:kid) { jwk[:kid].should == '12345' }
      its(:use) { jwk[:use].should == :sig }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
json-jwt-0.1.5 spec/json/jwk_spec.rb
json-jwt-0.1.4 spec/json/jwk_spec.rb
json-jwt-0.1.3 spec/json/jwk_spec.rb