您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

api_spec.rb 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. require 'sslcheck'
  2. module SSLCheck::SSLLabs
  3. describe API do
  4. URL = 'https://www.ssllabs.com/ssltest/analyze.html'
  5. it 'error' do
  6. stub_request(:get, URL).with(query: { d: 'imirhil.fr'})
  7. .to_return(status: 500)
  8. expect { API.new 'imirhil.fr' } .to raise_error ServerError, '500'
  9. end
  10. it 'waiting' do
  11. stub_request(:get, URL).with(query: { d: 'imirhil.fr'})
  12. .to_return(status: 200, body: File.read('spec/html/waiting.html'))
  13. expect { API.new 'imirhil.fr' } .to raise_error WaitingError
  14. end
  15. it 'single' do
  16. stub_request(:get, URL).with(query: { d: 'imirhil.fr'})
  17. .to_return(status: 200, body: File.read('spec/html/perfect.html'))
  18. results = API.new 'imirhil.fr'
  19. expect(results.hostname).to eq 'imirhil.fr'
  20. expect(results.ip).to eq '5.135.187.37'
  21. expect(results.rank).to eq 'A+'
  22. expect(results.ssl).to be false
  23. expect(results.tls).to be true
  24. expect(results.rc4).to be false
  25. expect(results.pfs).to be true
  26. expect(results.hsts).to be true
  27. expect(results.bits).to be 128
  28. end
  29. it 'multiple' do
  30. stub_request(:get, URL).with(query: { d: 'fortuneo.fr'})
  31. .to_return(status: 200, body: File.read('spec/html/multiple.html'))
  32. stub_request(:get, URL).with(query: { d: 'fortuneo.fr', s: '93.20.46.72'})
  33. .to_return(status: 200, body: File.read('spec/html/results.html'))
  34. results = API.new 'fortuneo.fr'
  35. expect(results.hostname).to eq 'fortuneo.fr'
  36. expect(results.ip).to eq '194.51.217.72'
  37. expect(results.rank).to eq 'B'
  38. expect(results.ssl).to be true
  39. expect(results.tls).to be false
  40. expect(results.rc4).to be true
  41. expect(results.pfs).to be false
  42. expect(results.hsts).to be false
  43. expect(results.bits).to be 128
  44. end
  45. end
  46. end