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.

server_spec.rb 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. require 'faketime'
  2. describe CryptCheck::Tls::Server do
  3. before :all do
  4. FakeTime.freeze Time.utc(2000, 1, 1)
  5. end
  6. after :all do
  7. FakeTime.unfreeze
  8. end
  9. describe '#md5_sign?' do
  10. it 'must detect server using MD5 certificate' do
  11. tls_serv do
  12. server = CryptCheck::Tls::TcpServer.new 'localhost', ::Socket::PF_INET, '127.0.0.1', 5000
  13. expect(server.md5_sign?).to be false
  14. end
  15. tls_serv material: [:md5, [:rsa, 1024]] do
  16. server = CryptCheck::Tls::TcpServer.new 'localhost', ::Socket::PF_INET, '127.0.0.1', 5000
  17. expect(server.md5_sign?).to be true
  18. end
  19. end
  20. end
  21. describe '#sha1_sign?' do
  22. it 'must detect server using SHA1 certificate' do
  23. tls_serv do
  24. server = CryptCheck::Tls::TcpServer.new 'localhost', ::Socket::PF_INET, '127.0.0.1', 5000
  25. expect(server.sha1_sign?).to be false
  26. end
  27. tls_serv material: [:sha1, [:rsa, 1024]] do
  28. server = CryptCheck::Tls::TcpServer.new 'localhost', ::Socket::PF_INET, '127.0.0.1', 5000
  29. expect(server.sha1_sign?).to be true
  30. end
  31. end
  32. end
  33. describe '#sha2_sign?' do
  34. it 'must detect server using SHA2 certificate' do
  35. tls_serv do
  36. server = CryptCheck::Tls::TcpServer.new 'localhost', ::Socket::PF_INET, '127.0.0.1', 5000
  37. expect(server.sha2_sign?).to be true
  38. end
  39. tls_serv material: [:md5, :sha1] do
  40. server = CryptCheck::Tls::TcpServer.new 'localhost', ::Socket::PF_INET, '127.0.0.1', 5000
  41. expect(server.sha2_sign?).to be false
  42. end
  43. end
  44. end
  45. end