Sha256: dd3e0b127475ae869888ca6eea19469a0bf344b5781a2fbab932a2de652eb745

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

module SSLCheck
  describe 'CommonNameValidatorSpec' do
    before do
      @cert = Certificate.new(VALID_CERT)
      @ca_bundle = [Certificate.new(CA_PARENT), Certificate.new(CA_GRAND_PARENT)]
    end
    context "when the common name is valid" do
      it 'should return nothing' do
        sut = Validators::CommonName.new("npboards.com", @cert, @ca_bundle)
        result = sut.validate
        expect(result).to_not be
      end
      context "when the certificate was issued to a wildcard domain" do
        it 'should return nothing' do
          wildcard_cert = Certificate.new(WILDCARD_CERT)
          sut = Validators::CommonName.new("example.squarespace.com", wildcard_cert, @ca_bundle)
          result = sut.validate
          expect(result).to_not be
        end
      end
      context "when the certificate has alternate subject names" do
        it 'should allow matches against the supplied common name' do
          sut = Validators::CommonName.new("npboards.com", @cert, @ca_bundle)
          result = sut.validate
          expect(result).to_not be
        end
      end

    end
    context "when the common name is mismatched" do
      it 'should return errors' do
        sut = Validators::CommonName.new("example.com", @cert, @ca_bundle)
        result = sut.validate
        expect(result).to be_a SSLCheck::Errors::Validation::CommonNameMismatch
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sslcheck-0.9.4 spec/common_name_validator_spec.rb
sslcheck-0.9.3 spec/common_name_validator_spec.rb
sslcheck-0.9.2 spec/common_name_validator_spec.rb
sslcheck-0.9.1 spec/common_name_validator_spec.rb
sslcheck-0.9.0 spec/common_name_validator_spec.rb