1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
require 'spec_helper'
describe JSON::JWK::Set do
let(:jwk) { public_key.to_jwk }
let(:set) { JSON::JWK::Set.new jwk }
describe '#content_type' do
it do
set.content_type.should == 'application/jwk-set+json'
end
end
context 'when single JWK given' do
subject { JSON::JWK::Set.new jwk }
it { should == [jwk] }
end
context 'when multiple JWKs given' do
subject { JSON::JWK::Set.new jwk, jwk }
it { should == [jwk, jwk] }
end
context 'when an Array of JWKs given' do
subject { JSON::JWK::Set.new [jwk, jwk] }
it { should == [jwk, jwk] }
end
context 'when JSON::JWK given' do
subject { JSON::JWK::Set.new jwk }
it 'should keep JSON::JWK' do
subject.each do |jwk|
jwk.should be_instance_of JSON::JWK
end
end
end
context 'when pure Hash given' do
subject { JSON::JWK::Set.new jwk.as_json }
it 'should convert into JSON::JWK' do
subject.each do |jwk|
jwk.should be_instance_of JSON::JWK
end
end
end
context 'when pure Hash with :keys key given' do
subject do
JSON::JWK::Set.new(
keys: jwk.as_json
)
end
it 'should convert into JSON::JWK' do
subject.each do |jwk|
jwk.should be_instance_of JSON::JWK
end
end
end
describe '#as_json' do
it 'should become proper JWK set format' do
json = set.as_json
json.should include :keys
json[:keys].should == [jwk]
end
end
describe '#to_json' do
it do
expect { set.to_json }.not_to raise_error
end
end
end
|