2017-11-23 08:09:44 +00:00
|
|
|
|
2015-08-23 20:21:04 +00:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class EmailHelperTest < ActiveSupport::TestCase
|
|
|
|
|
|
|
|
test 'a mx_records' do
|
|
|
|
|
|
|
|
domain = 'znuny.com'
|
|
|
|
mx_domains = EmailHelper.mx_records(domain)
|
|
|
|
assert_equal('arber.znuny.com', mx_domains[0])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'a email parser test' do
|
|
|
|
|
|
|
|
user, domain = EmailHelper.parse_email('somebody@example.com')
|
|
|
|
assert_equal('somebody', user)
|
|
|
|
assert_equal('example.com', domain)
|
|
|
|
|
|
|
|
user, domain = EmailHelper.parse_email('somebody+test@example.com')
|
|
|
|
assert_equal('somebody+test', user)
|
|
|
|
assert_equal('example.com', domain)
|
|
|
|
|
|
|
|
user, domain = EmailHelper.parse_email('somebody+testexample.com')
|
|
|
|
assert_not(user)
|
|
|
|
assert_not(domain)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'provider test' do
|
|
|
|
email = 'linus@kernel.org'
|
|
|
|
password = 'some_pw'
|
|
|
|
map = EmailHelper.provider(email, password)
|
|
|
|
|
2015-09-06 07:50:51 +00:00
|
|
|
assert_equal('imap', map[:google_imap][:inbound][:adapter])
|
|
|
|
assert_equal('imap.gmail.com', map[:google_imap][:inbound][:options][:host])
|
|
|
|
assert_equal(993, map[:google_imap][:inbound][:options][:port])
|
|
|
|
assert_equal(email, map[:google_imap][:inbound][:options][:user])
|
|
|
|
assert_equal(password, map[:google_imap][:inbound][:options][:password])
|
|
|
|
|
|
|
|
assert_equal('smtp', map[:google_imap][:outbound][:adapter])
|
|
|
|
assert_equal('smtp.gmail.com', map[:google_imap][:outbound][:options][:host])
|
|
|
|
assert_equal(25, map[:google_imap][:outbound][:options][:port])
|
|
|
|
assert_equal(true, map[:google_imap][:outbound][:options][:start_tls])
|
|
|
|
assert_equal(email, map[:google_imap][:outbound][:options][:user])
|
|
|
|
assert_equal(password, map[:google_imap][:outbound][:options][:password])
|
2015-08-23 20:21:04 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'provider_inbound_mx' do
|
|
|
|
|
|
|
|
email = 'linus@znuny.com'
|
|
|
|
password = 'some_pw'
|
|
|
|
user, domain = EmailHelper.parse_email(email)
|
|
|
|
mx_domains = EmailHelper.mx_records(domain)
|
|
|
|
map = EmailHelper.provider_inbound_mx(user, email, password, mx_domains)
|
|
|
|
|
|
|
|
assert_equal('imap', map[0][:adapter])
|
|
|
|
assert_equal('arber.znuny.com', map[0][:options][:host])
|
|
|
|
assert_equal(993, map[0][:options][:port])
|
|
|
|
assert_equal(user, map[0][:options][:user])
|
|
|
|
assert_equal(password, map[0][:options][:password])
|
|
|
|
|
|
|
|
assert_equal('imap', map[1][:adapter])
|
|
|
|
assert_equal('arber.znuny.com', map[1][:options][:host])
|
|
|
|
assert_equal(993, map[1][:options][:port])
|
|
|
|
assert_equal(email, map[1][:options][:user])
|
|
|
|
assert_equal(password, map[1][:options][:password])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'provider_inbound_guess' do
|
|
|
|
|
|
|
|
email = 'linus@znuny.com'
|
|
|
|
password = 'some_pw'
|
|
|
|
user, domain = EmailHelper.parse_email(email)
|
|
|
|
map = EmailHelper.provider_inbound_guess(user, email, password, domain)
|
|
|
|
|
|
|
|
assert_equal('imap', map[0][:adapter])
|
|
|
|
assert_equal('mail.znuny.com', map[0][:options][:host])
|
|
|
|
assert_equal(993, map[0][:options][:port])
|
|
|
|
assert_equal(user, map[0][:options][:user])
|
|
|
|
assert_equal(password, map[0][:options][:password])
|
|
|
|
|
|
|
|
assert_equal('imap', map[1][:adapter])
|
|
|
|
assert_equal('mail.znuny.com', map[1][:options][:host])
|
|
|
|
assert_equal(993, map[1][:options][:port])
|
|
|
|
assert_equal(email, map[1][:options][:user])
|
|
|
|
assert_equal(password, map[1][:options][:password])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'provider_outbound_mx' do
|
|
|
|
|
|
|
|
email = 'linus@znuny.com'
|
|
|
|
password = 'some_pw'
|
|
|
|
user, domain = EmailHelper.parse_email(email)
|
|
|
|
mx_domains = EmailHelper.mx_records(domain)
|
|
|
|
map = EmailHelper.provider_outbound_mx(user, email, password, mx_domains)
|
|
|
|
|
|
|
|
assert_equal('smtp', map[0][:adapter])
|
|
|
|
assert_equal('arber.znuny.com', map[0][:options][:host])
|
|
|
|
assert_equal(25, map[0][:options][:port])
|
|
|
|
assert_equal(true, map[0][:options][:start_tls])
|
|
|
|
assert_equal(user, map[0][:options][:user])
|
|
|
|
assert_equal(password, map[0][:options][:password])
|
|
|
|
|
|
|
|
assert_equal('smtp', map[1][:adapter])
|
|
|
|
assert_equal('arber.znuny.com', map[1][:options][:host])
|
|
|
|
assert_equal(25, map[1][:options][:port])
|
|
|
|
assert_equal(true, map[1][:options][:start_tls])
|
|
|
|
assert_equal(email, map[1][:options][:user])
|
|
|
|
assert_equal(password, map[1][:options][:password])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'provider_outbound_guess' do
|
|
|
|
|
|
|
|
email = 'linus@znuny.com'
|
|
|
|
password = 'some_pw'
|
|
|
|
user, domain = EmailHelper.parse_email(email)
|
|
|
|
map = EmailHelper.provider_outbound_guess(user, email, password, domain)
|
|
|
|
|
|
|
|
assert_equal('smtp', map[0][:adapter])
|
|
|
|
assert_equal('mail.znuny.com', map[0][:options][:host])
|
|
|
|
assert_equal(25, map[0][:options][:port])
|
|
|
|
assert_equal(true, map[0][:options][:start_tls])
|
|
|
|
assert_equal(user, map[0][:options][:user])
|
|
|
|
assert_equal(password, map[0][:options][:password])
|
|
|
|
|
|
|
|
assert_equal('smtp', map[1][:adapter])
|
|
|
|
assert_equal('mail.znuny.com', map[1][:options][:host])
|
|
|
|
assert_equal(25, map[1][:options][:port])
|
|
|
|
assert_equal(true, map[1][:options][:start_tls])
|
|
|
|
assert_equal(email, map[1][:options][:user])
|
|
|
|
assert_equal(password, map[1][:options][:password])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'z probe_inbound' do
|
|
|
|
|
2015-08-30 11:58:05 +00:00
|
|
|
# invalid adapter
|
|
|
|
result = EmailHelper::Probe.inbound(
|
|
|
|
adapter: 'imap2',
|
|
|
|
options: {
|
|
|
|
host: 'not_existsing_host',
|
|
|
|
port: 993,
|
|
|
|
ssl: true,
|
|
|
|
user: 'some@example.com',
|
|
|
|
password: 'password',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert_equal('failed', result[:result])
|
|
|
|
|
2015-08-23 20:21:04 +00:00
|
|
|
# network issues
|
|
|
|
result = EmailHelper::Probe.inbound(
|
|
|
|
adapter: 'imap',
|
|
|
|
options: {
|
|
|
|
host: 'not_existsing_host',
|
|
|
|
port: 993,
|
|
|
|
ssl: true,
|
|
|
|
user: 'some@example.com',
|
|
|
|
password: 'password',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert_equal('invalid', result[:result])
|
|
|
|
assert_equal('Hostname not found!', result[:message_human])
|
|
|
|
assert_equal('not_existsing_host', result[:settings][:options][:host])
|
|
|
|
|
|
|
|
result = EmailHelper::Probe.inbound(
|
|
|
|
adapter: 'imap',
|
|
|
|
options: {
|
2015-08-23 21:46:27 +00:00
|
|
|
host: 'www.znuny.com',
|
2015-08-23 20:21:04 +00:00
|
|
|
port: 993,
|
|
|
|
ssl: true,
|
|
|
|
user: 'some@example.com',
|
|
|
|
password: 'password',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
assert_equal('invalid', result[:result])
|
|
|
|
assert_equal('Connection refused!', result[:message_human])
|
2015-08-23 21:46:27 +00:00
|
|
|
assert_equal('www.znuny.com', result[:settings][:options][:host])
|
2015-08-23 20:21:04 +00:00
|
|
|
|
|
|
|
result = EmailHelper::Probe.inbound(
|
|
|
|
adapter: 'imap',
|
|
|
|
options: {
|
|
|
|
host: '172.42.42.42',
|
|
|
|
port: 993,
|
|
|
|
ssl: true,
|
|
|
|
user: 'some@example.com',
|
|
|
|
password: 'password',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
assert_equal('invalid', result[:result])
|
2015-08-23 22:48:06 +00:00
|
|
|
assert_match(/Host not reachable|No route to host/, result[:message_human])
|
2015-08-23 20:21:04 +00:00
|
|
|
assert_equal('172.42.42.42', result[:settings][:options][:host])
|
|
|
|
|
|
|
|
# gmail
|
|
|
|
result = EmailHelper::Probe.inbound(
|
|
|
|
adapter: 'imap',
|
|
|
|
options: {
|
|
|
|
host: 'imap.gmail.com',
|
|
|
|
port: 993,
|
|
|
|
ssl: true,
|
|
|
|
user: 'some@example.com',
|
|
|
|
password: 'password',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
assert_equal('invalid', result[:result])
|
2017-09-23 06:25:55 +00:00
|
|
|
assert_match(/Authentication failed, username incorrect|Authentication failed, invalid credentials/, result[:message_human])
|
2015-08-23 20:21:04 +00:00
|
|
|
assert_equal('imap.gmail.com', result[:settings][:options][:host])
|
|
|
|
|
|
|
|
result = EmailHelper::Probe.inbound(
|
|
|
|
adapter: 'imap',
|
|
|
|
options: {
|
|
|
|
host: 'imap.gmail.com',
|
|
|
|
port: 993,
|
|
|
|
ssl: true,
|
|
|
|
user: 'frank.tailor05@googlemail.com',
|
|
|
|
password: 'password',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
assert_equal('invalid', result[:result])
|
2015-08-24 07:24:32 +00:00
|
|
|
|
|
|
|
# if we have to many failed logins, we need to handle another error message
|
2017-09-23 06:25:55 +00:00
|
|
|
if result[:message_human].present?
|
|
|
|
assert_match(/Authentication failed, username incorrect|Authentication failed, invalid credentials/, result[:message_human])
|
2015-08-24 07:24:32 +00:00
|
|
|
else
|
|
|
|
assert_match(/Web login required/, result[:message])
|
|
|
|
end
|
2015-08-23 20:21:04 +00:00
|
|
|
assert_equal('imap.gmail.com', result[:settings][:options][:host])
|
|
|
|
|
|
|
|
# dovecot
|
|
|
|
result = EmailHelper::Probe.inbound(
|
|
|
|
adapter: 'imap',
|
|
|
|
options: {
|
|
|
|
host: 'arber.znuny.com',
|
|
|
|
port: 993,
|
|
|
|
ssl: true,
|
|
|
|
user: 'some@example.com',
|
|
|
|
password: 'password',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
assert_equal('invalid', result[:result])
|
|
|
|
assert_equal('Authentication failed!', result[:message_human])
|
|
|
|
assert_equal('arber.znuny.com', result[:settings][:options][:host])
|
|
|
|
|
|
|
|
# realtest - test I
|
|
|
|
if !ENV['EMAILHELPER_MAILBOX_1']
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
2015-08-23 20:21:04 +00:00
|
|
|
end
|
|
|
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
|
|
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
|
|
|
user, domain = EmailHelper.parse_email(mailbox_user)
|
|
|
|
result = EmailHelper::Probe.inbound(
|
|
|
|
adapter: 'imap',
|
|
|
|
options: {
|
|
|
|
host: 'arber.znuny.com',
|
|
|
|
port: 993,
|
|
|
|
ssl: true,
|
|
|
|
user: user,
|
|
|
|
password: mailbox_password,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
assert_equal('ok', result[:result])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'z probe_outbound' do
|
|
|
|
|
2015-08-30 11:58:05 +00:00
|
|
|
# invalid adapter
|
|
|
|
result = EmailHelper::Probe.outbound(
|
|
|
|
{
|
|
|
|
adapter: 'smtp2',
|
|
|
|
options: {
|
|
|
|
host: 'not_existsing_host',
|
|
|
|
port: 25,
|
|
|
|
start_tls: true,
|
|
|
|
user: 'some@example.com',
|
|
|
|
password: 'password',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'some@example.com',
|
|
|
|
)
|
|
|
|
|
|
|
|
assert_equal('failed', result[:result])
|
|
|
|
|
2015-08-23 20:21:04 +00:00
|
|
|
# network issues
|
|
|
|
result = EmailHelper::Probe.outbound(
|
|
|
|
{
|
|
|
|
adapter: 'smtp',
|
|
|
|
options: {
|
|
|
|
host: 'not_existsing_host',
|
|
|
|
port: 25,
|
|
|
|
start_tls: true,
|
|
|
|
user: 'some@example.com',
|
|
|
|
password: 'password',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'some@example.com',
|
|
|
|
)
|
|
|
|
|
|
|
|
assert_equal('invalid', result[:result])
|
|
|
|
assert_equal('Hostname not found!', result[:message_human])
|
|
|
|
assert_equal('not_existsing_host', result[:settings][:options][:host])
|
|
|
|
|
|
|
|
result = EmailHelper::Probe.outbound(
|
|
|
|
{
|
|
|
|
adapter: 'smtp',
|
|
|
|
options: {
|
2015-08-23 21:46:27 +00:00
|
|
|
host: 'www.znuny.com',
|
|
|
|
port: 26,
|
2015-08-23 20:21:04 +00:00
|
|
|
start_tls: true,
|
|
|
|
user: 'some@example.com',
|
|
|
|
password: 'password',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'some@example.com',
|
|
|
|
)
|
|
|
|
assert_equal('invalid', result[:result])
|
|
|
|
assert_equal('Connection refused!', result[:message_human])
|
2015-08-23 21:46:27 +00:00
|
|
|
assert_equal('www.znuny.com', result[:settings][:options][:host])
|
2015-08-23 20:21:04 +00:00
|
|
|
|
|
|
|
result = EmailHelper::Probe.outbound(
|
|
|
|
{
|
|
|
|
adapter: 'smtp',
|
|
|
|
options: {
|
|
|
|
host: '172.42.42.42',
|
|
|
|
port: 25,
|
|
|
|
start_tls: true,
|
|
|
|
user: 'some@example.com',
|
|
|
|
password: 'password',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'some@example.com',
|
|
|
|
)
|
|
|
|
assert_equal('invalid', result[:result])
|
2015-08-23 22:48:06 +00:00
|
|
|
assert_match(/Host not reachable|No route to host/, result[:message_human])
|
2015-08-23 20:21:04 +00:00
|
|
|
assert_equal('172.42.42.42', result[:settings][:options][:host])
|
|
|
|
|
|
|
|
# gmail
|
|
|
|
result = EmailHelper::Probe.outbound(
|
|
|
|
{
|
|
|
|
adapter: 'smtp',
|
|
|
|
options: {
|
|
|
|
host: 'smtp.gmail.com',
|
|
|
|
port: 25,
|
|
|
|
start_tls: true,
|
|
|
|
user: 'some@example.com',
|
|
|
|
password: 'password',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'some@example.com',
|
|
|
|
)
|
|
|
|
assert_equal('invalid', result[:result])
|
|
|
|
assert_equal('Authentication failed!', result[:message_human])
|
|
|
|
assert_equal('smtp.gmail.com', result[:settings][:options][:host])
|
|
|
|
|
|
|
|
result = EmailHelper::Probe.outbound(
|
|
|
|
{
|
|
|
|
adapter: 'smtp',
|
|
|
|
options: {
|
|
|
|
host: 'smtp.gmail.com',
|
|
|
|
port: 25,
|
|
|
|
start_tls: true,
|
|
|
|
user: 'frank.tailor05@googlemail.com',
|
|
|
|
password: 'password',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'some@example.com',
|
|
|
|
)
|
|
|
|
assert_equal('invalid', result[:result])
|
2015-08-24 07:24:32 +00:00
|
|
|
|
|
|
|
# if we have to many failed logins, we need to handle another error message
|
2017-11-23 08:09:44 +00:00
|
|
|
if result[:message_human].present?
|
2015-08-24 07:24:32 +00:00
|
|
|
assert_equal('Authentication failed!', result[:message_human])
|
|
|
|
else
|
2015-08-24 07:37:50 +00:00
|
|
|
assert_match(/Please log in with your web browser and then try again/, result[:message])
|
2015-08-24 07:24:32 +00:00
|
|
|
end
|
2015-08-23 20:21:04 +00:00
|
|
|
assert_equal('smtp.gmail.com', result[:settings][:options][:host])
|
|
|
|
|
|
|
|
# dovecot
|
|
|
|
result = EmailHelper::Probe.outbound(
|
|
|
|
{
|
|
|
|
adapter: 'smtp',
|
|
|
|
options: {
|
|
|
|
host: 'arber.znuny.com',
|
|
|
|
port: 25,
|
|
|
|
start_tls: true,
|
|
|
|
user: 'some@example.com',
|
|
|
|
password: 'password',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'some@example.com',
|
|
|
|
)
|
|
|
|
assert_equal('invalid', result[:result])
|
|
|
|
assert_equal('Authentication failed!', result[:message_human])
|
|
|
|
assert_equal('arber.znuny.com', result[:settings][:options][:host])
|
|
|
|
|
|
|
|
# realtest - test I
|
|
|
|
if !ENV['EMAILHELPER_MAILBOX_1']
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
2015-08-23 20:21:04 +00:00
|
|
|
end
|
|
|
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
|
|
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
|
|
|
user, domain = EmailHelper.parse_email(mailbox_user)
|
|
|
|
result = EmailHelper::Probe.outbound(
|
|
|
|
{
|
|
|
|
adapter: 'smtp',
|
|
|
|
options: {
|
|
|
|
host: 'arber.znuny.com',
|
|
|
|
port: 25,
|
|
|
|
start_tls: true,
|
|
|
|
user: user,
|
|
|
|
password: mailbox_password,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mailbox_user,
|
|
|
|
)
|
|
|
|
assert_equal('ok', result[:result])
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'zz probe' do
|
|
|
|
|
|
|
|
result = EmailHelper::Probe.full(
|
|
|
|
email: 'invalid_format',
|
|
|
|
password: 'somepass',
|
|
|
|
)
|
|
|
|
assert_equal('invalid', result[:result])
|
|
|
|
assert_not(result[:setting])
|
|
|
|
|
2015-09-06 07:50:51 +00:00
|
|
|
# realtest - test I, with imap
|
2015-08-23 20:21:04 +00:00
|
|
|
if !ENV['EMAILHELPER_MAILBOX_1']
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
2015-08-23 20:21:04 +00:00
|
|
|
end
|
|
|
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
|
|
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
|
|
|
|
|
|
|
result = EmailHelper::Probe.full(
|
|
|
|
email: mailbox_user,
|
|
|
|
password: mailbox_password,
|
|
|
|
)
|
|
|
|
assert_equal('ok', result[:result])
|
|
|
|
assert_equal('arber.znuny.com', result[:setting][:inbound][:options][:host])
|
|
|
|
assert_equal('arber.znuny.com', result[:setting][:outbound][:options][:host])
|
|
|
|
|
2015-09-06 07:50:51 +00:00
|
|
|
# realtest - test II, gmail with only pop3
|
|
|
|
if !ENV['EMAILHELPER_MAILBOX_2']
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "Need EMAILHELPER_MAILBOX_2 as ENV variable like export EMAILHELPER_MAILBOX_2='hansb36621@gmail.com:somepass'"
|
2015-09-06 07:50:51 +00:00
|
|
|
end
|
|
|
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_2'].split(':')[0]
|
|
|
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_2'].split(':')[1]
|
|
|
|
|
|
|
|
result = EmailHelper::Probe.full(
|
|
|
|
email: mailbox_user,
|
|
|
|
password: mailbox_password,
|
|
|
|
)
|
2017-09-23 06:25:55 +00:00
|
|
|
assert_nil(result[:reason])
|
2015-09-06 07:50:51 +00:00
|
|
|
assert_equal('ok', result[:result])
|
|
|
|
assert_equal('pop.gmail.com', result[:setting][:inbound][:options][:host])
|
|
|
|
assert_equal('smtp.gmail.com', result[:setting][:outbound][:options][:host])
|
|
|
|
|
2015-08-23 20:21:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'zz verify' do
|
|
|
|
|
2015-09-06 07:50:51 +00:00
|
|
|
# realtest - test I, with imap
|
2015-08-23 20:21:04 +00:00
|
|
|
if !ENV['EMAILHELPER_MAILBOX_1']
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
2015-08-23 20:21:04 +00:00
|
|
|
end
|
|
|
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
|
|
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
|
|
|
user, domain = EmailHelper.parse_email(mailbox_user)
|
|
|
|
result = EmailHelper::Verify.email(
|
|
|
|
inbound: {
|
|
|
|
adapter: 'imap',
|
|
|
|
options: {
|
|
|
|
host: 'arber.znuny.com',
|
|
|
|
port: 993,
|
|
|
|
ssl: true,
|
|
|
|
user: user,
|
|
|
|
password: mailbox_password,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
outbound: {
|
|
|
|
adapter: 'smtp',
|
|
|
|
options: {
|
|
|
|
host: 'arber.znuny.com',
|
|
|
|
port: 25,
|
|
|
|
start_tls: true,
|
|
|
|
user: user,
|
|
|
|
password: mailbox_password,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
sender: mailbox_user,
|
|
|
|
)
|
|
|
|
assert_equal('ok', result[:result])
|
2015-09-06 07:50:51 +00:00
|
|
|
|
|
|
|
# realtest - test II, gmail with pop3
|
|
|
|
if !ENV['EMAILHELPER_MAILBOX_2']
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "Need EMAILHELPER_MAILBOX_2 as ENV variable like export EMAILHELPER_MAILBOX_2='hansb36621@gmail.com:somepass'"
|
2015-09-06 07:50:51 +00:00
|
|
|
end
|
|
|
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_2'].split(':')[0]
|
|
|
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_2'].split(':')[1]
|
|
|
|
user, domain = EmailHelper.parse_email(mailbox_user)
|
|
|
|
result = EmailHelper::Verify.email(
|
|
|
|
inbound: {
|
|
|
|
adapter: 'pop3',
|
|
|
|
options: {
|
|
|
|
host: 'pop.gmail.com',
|
|
|
|
port: 995,
|
|
|
|
ssl: true,
|
|
|
|
user: mailbox_user,
|
|
|
|
password: mailbox_password,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
outbound: {
|
|
|
|
adapter: 'smtp',
|
|
|
|
options: {
|
|
|
|
host: 'smtp.gmail.com',
|
|
|
|
port: 25,
|
|
|
|
start_tls: true,
|
|
|
|
user: mailbox_user,
|
|
|
|
password: mailbox_password,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
sender: mailbox_user,
|
|
|
|
)
|
|
|
|
assert_equal('ok', result[:result])
|
|
|
|
|
2015-08-23 20:21:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|