Advertisement
Guest User

Untitled

a guest
Oct 14th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. require "rubygems"
  4. gem "rspec"
  5.  
  6. require './Helpers/email.rb'
  7. require './Helpers/email_pmta.rb'
  8.  
  9. require './Helpers/utils.rb'
  10. require './Helpers/utils_email.rb'
  11.  
  12. require './Helpers/selen.rb'
  13. require '../Settings/data.rb'
  14. require './Helpers/campaign_stats.rb'
  15.  
  16. require 'postmark'
  17.  
  18. describe "Email through SMTP" do
  19.  
  20. attr_accessor :postmarkusername,
  21. :postmarkpassword,
  22. :message,
  23. :servicetype,
  24. :smtp
  25.  
  26. include Utils
  27. include EmailUtils
  28. include Selen
  29.  
  30. before(:all) do
  31.  
  32. @message = Mail.new
  33. @message.from = $FROM_EMAIL
  34. @message.to = $TO_EMAIL
  35. @servicetype = $SMTP
  36.  
  37. # subject with random number so it's unique
  38. @message.subject = "Test email sent" + get_random_number(5).to_s + "by #{@servicetype}"
  39. @message.content_type = "text/html"
  40. @message.body = "Test email sent"
  41.  
  42. @postmarkusername = $USERNAME
  43. @postmarkpassword = $PASSWORD
  44.  
  45. init_selenium($PORT,$BROWSERTYPE + $BROWSERURL,$WEBSITE)
  46.  
  47. end
  48.  
  49. before(:each) do
  50. start_selenium_session
  51. end
  52.  
  53. append_after(:each) do
  54. stop_selenium_session
  55. end
  56.  
  57. it "should be sent through LOAD BALANCER by host #{$SLBHOST}" do
  58.  
  59. puts "check #{$RECEIVE_EMAIL} account:"
  60.  
  61. # subject with random number so it's unique
  62. @message.subject = "Test email sent " + get_random_number(5).to_s + " by host #{$SLBHOST}"
  63.  
  64. mail = Mailing.new
  65. mail.set_sending_details($SLBHOST,25,"mail.igor.wildbit.com",convert_email_to_string(@message.from),$API_TOKEN,$API_TOKEN)
  66. mail.send(@message.subject,@message.body,convert_email_to_string(@message.to),false)
  67.  
  68. # change emergency contacts to wider range
  69. temp_contacts = $EMERGENCY_CONTACTS
  70. $EMERGENCY_CONTACTS = $EMERGENCY_CONTACTS_ALL
  71.  
  72. # check if email arrived
  73. check_email(@message.subject)
  74.  
  75. $EMERGENCY_CONTACTS = temp_contacts
  76.  
  77. write_stats(@message.subject,is_email_delayed,get_email_delayed_time,get_email_sent_time,$STAT_CONTACTS)
  78.  
  79. # check if email showed up in activity page
  80. check_email_in_activity_page(@postmarkusername,@postmarkpassword,@message.subject,@message.to)
  81.  
  82. end
  83.  
  84. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement