Sha256: a8d9842a3c9eb41a283174dc8e32f90508c64f9d7b254a2f07927638fe6ec23f

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

require 'spec_helper'

include R509::Cert::Extensions

shared_examples_for "a correct R509 OCSPNoCheck object" do |critical|
  before :all do
    extension_name = "noCheck"
    klass = OCSPNoCheck
    ef = OpenSSL::X509::ExtensionFactory.new
    openssl_ext = ef.create_extension( extension_name, "irrelevant", critical)
    @r509_ext = klass.new( openssl_ext )
  end

  it "has the expected type" do
    @r509_ext.oid.should == "noCheck"
  end

  it "reports #critical? properly" do
    @r509_ext.critical?.should == critical
  end
end

describe R509::Cert::Extensions::OCSPNoCheck do
  include R509::Cert::Extensions

  context "OCSPNoCheck" do
    context "creation & yaml generation" do
      context "when passed a hash" do
        before :all do
          @no_check = R509::Cert::Extensions::OCSPNoCheck.new({})
        end

        it "creates extension" do
          @no_check.should_not be_nil
        end

        it "builds yaml" do
          YAML.load(@no_check.to_yaml).should == {:critical=>false}
        end
      end

      context "default criticality" do
        before :all do
          @no_check = R509::Cert::Extensions::OCSPNoCheck.new({})
        end

        it "creates extension" do
          @no_check.critical?.should be_false
        end

        it "builds yaml" do
          YAML.load(@no_check.to_yaml).should == {:critical => false}
        end
      end

      context "non-default criticality" do
        before :all do
          @no_check = R509::Cert::Extensions::OCSPNoCheck.new(:critical => true)
        end

        it "creates extension" do
          @no_check.critical?.should be_true
        end

        it "builds yaml" do
          YAML.load(@no_check.to_yaml).should == {:critical => true}
        end
      end

    end

    it_should_behave_like "a correct R509 OCSPNoCheck object", false
    it_should_behave_like "a correct R509 OCSPNoCheck object", true
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
r509-0.10.0 spec/cert/extensions/ocsp_no_check_spec.rb