nick_ponorets

virus_total_spec

Jan 17th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. require 'spec_helper'
  2.  
  3. describe 'VirusTotal Public API' do
  4.  
  5. url = Airborne.configuration.virus_total_url
  6. api_key = Airborne.configuration.virus_total_api_key
  7. resource = Airborne.configuration.virus_total_resource
  8.  
  9. context 'RESCAN' do
  10. before(:all) do
  11. @tap = Airborne::TapcoreApi.new(url)
  12. @tap.virus_total_rescan(url, api_key, resource)
  13. end
  14.  
  15. context 'RESPONSE' do
  16. it 'should be set' do
  17. expect(response).to_not be(nil)
  18. end
  19. end
  20.  
  21. context 'HEADERS' do
  22. it 'should be set' do
  23. puts "Response headers: #{headers}"
  24. expect(headers).to_not be(nil)
  25. end
  26.  
  27. it 'correct content-type' do
  28. expect_header('content-type', 'application/json')
  29. end
  30. end
  31.  
  32. context 'BODY' do
  33. it 'should be set' do
  34. puts "Response body: #{body}"
  35. puts "Response body size: #{body.size} B"
  36. expect(body).to_not be(nil)
  37. end
  38. end
  39.  
  40. context 'STATUS' do
  41. it 'should be set' do
  42. expect(status).to_not be(nil)
  43. end
  44.  
  45. it 'correct status' do
  46. expect_status 200
  47. end
  48. end
  49.  
  50. context 'JSON' do
  51. it 'should be set' do
  52. expect(body).to_not be(nil)
  53. end
  54.  
  55. it 'correct response code value' do
  56. expect(json_body[:response_code]).to eq(1)
  57. end
  58. end
  59.  
  60. context 'RESPONSE TIME' do
  61. it 'correct response time' do
  62. puts "Response time: #{response_time} sec"
  63. expect(response_time).to be < 20
  64. end
  65. end
  66. end
  67.  
  68. context 'REPORT' do
  69. before(:all) do
  70. @tap = Airborne::TapcoreApi.new(url)
  71. @tap.virus_total_report(url, api_key, resource)
  72. end
  73.  
  74. context 'RESPONSE' do
  75. it 'should be set' do
  76. expect(response).to_not be(nil)
  77. end
  78. end
  79.  
  80. context 'HEADERS' do
  81. it 'should be set' do
  82. puts "Response headers: #{headers}"
  83. expect(headers).to_not be(nil)
  84. end
  85.  
  86. it 'correct content-type' do
  87. expect_header('content-type', 'application/json')
  88. end
  89. end
  90.  
  91. context 'BODY' do
  92. it 'should be set' do
  93. puts "Response body: #{body}"
  94. puts "Response body size: #{body.size} B"
  95. expect(body).to_not be(nil)
  96. end
  97. end
  98.  
  99. context 'STATUS' do
  100. it 'should be set' do
  101. expect(status).to_not be(nil)
  102. end
  103.  
  104. it 'correct status' do
  105. expect_status 200
  106. end
  107. end
  108.  
  109. context 'JSON' do
  110. it 'should be set' do
  111. expect(body).to_not be(nil)
  112. end
  113.  
  114. it 'correct response code value' do
  115. expect(json_body[:response_code]).to eq(1)
  116. end
  117.  
  118. it 'correct positives value' do
  119. expect(json_body[:positives]).to be <= 1
  120. end
  121. end
  122.  
  123. context 'RESPONSE TIME' do
  124. it 'correct response time' do
  125. puts "Response time: #{response_time} sec"
  126. expect(response_time).to be < 20
  127. end
  128. end
  129. end
  130. end
Add Comment
Please, Sign In to add comment