Sha256: 2efa1181ce216926a31699e9255e032a0fb6d925fbf2973dc8801feac3cd2898

Contents?: true

Size: 1.47 KB

Versions: 3

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'
require 'r509/oid_mapper'


# NOTE
# The nature of OID registration means that the state does NOT get reset between
# each test. Accordingly, we MUST use OIDs (and short names) here that will not
# be present in any other tests (or in the real world)

describe R509::OIDMapper do
  it "registers one new oid" do
    subject = R509::Subject.new [['1.4.3.2.1.2.3.5.5.5.5.5','random_oid']]
    subject['1.4.3.2.1.2.3.5.5.5.5.5'].should == 'random_oid'
    expect { R509::Subject.new [['myOIDName','random_oid']] }.to raise_error(OpenSSL::X509::NameError,'invalid field name')

    R509::OIDMapper.register('1.4.3.2.1.2.3.5.5.5.5.5','myOIDName').should == true
    subject_new = R509::Subject.new [['myOIDName','random_oid']]
    subject_new['myOIDName'].should == 'random_oid'
  end
  it "registers a batch of new oids" do
    expect { R509::Subject.new [['testOIDName','random_oid']] }.to raise_error(OpenSSL::X509::NameError,'invalid field name')
    expect { R509::Subject.new [['anotherOIDName','second_random']] }.to raise_error(OpenSSL::X509::NameError,'invalid field name')
    R509::OIDMapper.batch_register([
    {:oid => '1.4.3.2.1.2.3.4.4.4.4', :short_name => 'testOIDName'},
    {:oid => '1.4.3.2.1.2.5.4.4.4.4', :short_name => 'anotherOIDName'}
    ])
    subject_new = R509::Subject.new [['testOIDName','random_oid'],['anotherOIDName','second_random']]
    subject_new['testOIDName'].should == 'random_oid'
    subject_new['anotherOIDName'].should == 'second_random'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
r509-0.9.2 spec/oid_mapper_spec.rb
r509-0.9.1 spec/oid_mapper_spec.rb
r509-0.9 spec/oid_mapper_spec.rb