You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cert_spec.rb 1.1KB

1234567891011121314151617181920212223242526272829303132
  1. describe CryptCheck::Tls::Cert do
  2. def load_chain(chain)
  3. chain.collect { |f| ::OpenSSL::X509::Certificate.new File.read File.join 'spec/resources', "#{f}.crt" }
  4. end
  5. describe '::trusted?' do
  6. it 'must accept valid certificat' do
  7. cert, *chain, ca = load_chain %w(custom intermediate ca)
  8. trust = ::CryptCheck::Tls::Cert.trusted? cert, chain, roots: ca
  9. expect(trust).to eq :trusted
  10. end
  11. it 'must reject self signed certificate' do
  12. cert, ca = load_chain %w(self-signed ca)
  13. trust = ::CryptCheck::Tls::Cert.trusted? cert, [], roots: ca
  14. expect(trust).to eq 'self signed certificate'
  15. end
  16. it 'must reject unknown CA' do
  17. cert, *chain = load_chain %w(custom intermediate ca)
  18. trust = ::CryptCheck::Tls::Cert.trusted? cert, chain, roots: []
  19. expect(trust).to eq 'unable to get issuer certificate'
  20. end
  21. it 'must reject missing intermediate chain' do
  22. cert, ca = load_chain %w(custom ca)
  23. chain = []
  24. trust = ::CryptCheck::Tls::Cert.trusted? cert, chain, roots: ca
  25. expect(trust).to eq 'unable to get local issuer certificate'
  26. end
  27. end
  28. end