Sha256: 465f31d211a295075c689df5aa8ec4d0a0a49a83152ae473f34a634c35fcdeb9

Contents?: true

Size: 1.48 KB

Versions: 27

Compression:

Stored size: 1.48 KB

Contents

# -*- encoding: utf-8 -*-

require 'test_helper'
require 'hexapdf/digital_signature'

describe HexaPDF::DigitalSignature::VerificationResult do
  describe "Message" do
    it "accepts a type and a content argument on creation" do
      m = HexaPDF::DigitalSignature::VerificationResult::Message.new(:type, 'content')
      assert_equal(:type, m.type)
      assert_equal('content', m.content)
    end

    it "allows sorting by type" do
      info =  HexaPDF::DigitalSignature::VerificationResult::Message.new(:info, 'c')
      warning = HexaPDF::DigitalSignature::VerificationResult::Message.new(:warning, 'c')
      error = HexaPDF::DigitalSignature::VerificationResult::Message.new(:error, 'c')
      assert_equal([error, warning, info], [info, error, warning].sort)
    end
  end

  before do
    @result = HexaPDF::DigitalSignature::VerificationResult.new
  end

  it "can add new messages" do
    @result.log(:error, "content")
    assert_equal(1, @result.messages.size)
    assert_equal(:error, @result.messages[0].type)
    assert_equal('content', @result.messages[0].content)
  end

  it "reports success if no error messages have been logged" do
    assert(@result.success?)
    @result.log(:info, 'content')
    assert(@result.success?)
    @result.log(:error, 'failure')
    refute(@result.success?)
  end

  it "reports failure if there is at least one error message" do
    @result.log(:info, 'content')
    refute(@result.failure?)
    @result.log(:error, 'failure')
    assert(@result.failure?)
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
hexapdf-1.0.2 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-1.0.1 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-1.0.0 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.47.0 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.46.0 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.45.0 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.44.0 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.41.0 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.40.0 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.39.1 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.39.0 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.38.0 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.37.2 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.37.1 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.37.0 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.36.0 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.35.1 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.35.0 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.34.1 test/hexapdf/digital_signature/test_verification_result.rb
hexapdf-0.34.0 test/hexapdf/digital_signature/test_verification_result.rb