Maintenance: Migrate email tests to new host.
This commit is contained in:
parent
e42d62d1c6
commit
343415d6e8
4 changed files with 61 additions and 48 deletions
|
@ -1,4 +1,4 @@
|
||||||
module EmailHelper
|
class EmailHelper
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
|
@ -454,6 +454,24 @@ returns
|
||||||
password: password,
|
password: password,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
adapter: 'smtp',
|
||||||
|
options: {
|
||||||
|
host: domain,
|
||||||
|
port: 587,
|
||||||
|
user: user,
|
||||||
|
password: password,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
adapter: 'smtp',
|
||||||
|
options: {
|
||||||
|
host: domain,
|
||||||
|
port: 587,
|
||||||
|
user: email,
|
||||||
|
password: password,
|
||||||
|
},
|
||||||
|
},
|
||||||
]
|
]
|
||||||
outbounds = outbounds.concat(outbound)
|
outbounds = outbounds.concat(outbound)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module EmailHelper
|
class EmailHelper
|
||||||
class Probe
|
class Probe
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -400,6 +400,7 @@ returns on fail
|
||||||
'Incorrect username' => 'Authentication failed, username incorrect!',
|
'Incorrect username' => 'Authentication failed, username incorrect!',
|
||||||
'Lookup failed' => 'Authentication failed, username incorrect!',
|
'Lookup failed' => 'Authentication failed, username incorrect!',
|
||||||
'Invalid credentials' => 'Authentication failed, invalid credentials!',
|
'Invalid credentials' => 'Authentication failed, invalid credentials!',
|
||||||
|
'authentication not enabled' => 'Authentication not possible (not offered by the service)',
|
||||||
'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!',
|
'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!',
|
||||||
'getaddrinfo: Name or service not known' => 'Hostname not found!',
|
'getaddrinfo: Name or service not known' => 'Hostname not found!',
|
||||||
'No route to host' => 'No route to host!',
|
'No route to host' => 'No route to host!',
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module EmailHelper
|
class EmailHelper
|
||||||
class Verify
|
class Verify
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
|
@ -4,9 +4,9 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
test 'a mx_records' do
|
test 'a mx_records' do
|
||||||
|
|
||||||
domain = 'znuny.com'
|
domain = 'zammad.com'
|
||||||
mx_domains = EmailHelper.mx_records(domain)
|
mx_domains = EmailHelper.mx_records(domain)
|
||||||
assert_equal('arber.znuny.com', mx_domains[0])
|
assert_equal('mx2.zammad.com', mx_domains[0])
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,20 +48,20 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
test 'provider_inbound_mx' do
|
test 'provider_inbound_mx' do
|
||||||
|
|
||||||
email = 'linus@znuny.com'
|
email = 'linus@zammad.com'
|
||||||
password = 'some_pw'
|
password = 'some_pw'
|
||||||
user, domain = EmailHelper.parse_email(email)
|
user, domain = EmailHelper.parse_email(email)
|
||||||
mx_domains = EmailHelper.mx_records(domain)
|
mx_domains = EmailHelper.mx_records(domain)
|
||||||
map = EmailHelper.provider_inbound_mx(user, email, password, mx_domains)
|
map = EmailHelper.provider_inbound_mx(user, email, password, mx_domains)
|
||||||
|
|
||||||
assert_equal('imap', map[0][:adapter])
|
assert_equal('imap', map[0][:adapter])
|
||||||
assert_equal('arber.znuny.com', map[0][:options][:host])
|
assert_equal('mx2.zammad.com', map[0][:options][:host])
|
||||||
assert_equal(993, map[0][:options][:port])
|
assert_equal(993, map[0][:options][:port])
|
||||||
assert_equal(user, map[0][:options][:user])
|
assert_equal(user, map[0][:options][:user])
|
||||||
assert_equal(password, map[0][:options][:password])
|
assert_equal(password, map[0][:options][:password])
|
||||||
|
|
||||||
assert_equal('imap', map[1][:adapter])
|
assert_equal('imap', map[1][:adapter])
|
||||||
assert_equal('arber.znuny.com', map[1][:options][:host])
|
assert_equal('mx2.zammad.com', map[1][:options][:host])
|
||||||
assert_equal(993, map[1][:options][:port])
|
assert_equal(993, map[1][:options][:port])
|
||||||
assert_equal(email, map[1][:options][:user])
|
assert_equal(email, map[1][:options][:user])
|
||||||
assert_equal(password, map[1][:options][:password])
|
assert_equal(password, map[1][:options][:password])
|
||||||
|
@ -70,19 +70,19 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
test 'provider_inbound_guess' do
|
test 'provider_inbound_guess' do
|
||||||
|
|
||||||
email = 'linus@znuny.com'
|
email = 'linus@zammad.com'
|
||||||
password = 'some_pw'
|
password = 'some_pw'
|
||||||
user, domain = EmailHelper.parse_email(email)
|
user, domain = EmailHelper.parse_email(email)
|
||||||
map = EmailHelper.provider_inbound_guess(user, email, password, domain)
|
map = EmailHelper.provider_inbound_guess(user, email, password, domain)
|
||||||
|
|
||||||
assert_equal('imap', map[0][:adapter])
|
assert_equal('imap', map[0][:adapter])
|
||||||
assert_equal('mail.znuny.com', map[0][:options][:host])
|
assert_equal('mail.zammad.com', map[0][:options][:host])
|
||||||
assert_equal(993, map[0][:options][:port])
|
assert_equal(993, map[0][:options][:port])
|
||||||
assert_equal(user, map[0][:options][:user])
|
assert_equal(user, map[0][:options][:user])
|
||||||
assert_equal(password, map[0][:options][:password])
|
assert_equal(password, map[0][:options][:password])
|
||||||
|
|
||||||
assert_equal('imap', map[1][:adapter])
|
assert_equal('imap', map[1][:adapter])
|
||||||
assert_equal('mail.znuny.com', map[1][:options][:host])
|
assert_equal('mail.zammad.com', map[1][:options][:host])
|
||||||
assert_equal(993, map[1][:options][:port])
|
assert_equal(993, map[1][:options][:port])
|
||||||
assert_equal(email, map[1][:options][:user])
|
assert_equal(email, map[1][:options][:user])
|
||||||
assert_equal(password, map[1][:options][:password])
|
assert_equal(password, map[1][:options][:password])
|
||||||
|
@ -91,21 +91,21 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
test 'provider_outbound_mx' do
|
test 'provider_outbound_mx' do
|
||||||
|
|
||||||
email = 'linus@znuny.com'
|
email = 'linus@zammad.com'
|
||||||
password = 'some_pw'
|
password = 'some_pw'
|
||||||
user, domain = EmailHelper.parse_email(email)
|
user, domain = EmailHelper.parse_email(email)
|
||||||
mx_domains = EmailHelper.mx_records(domain)
|
mx_domains = EmailHelper.mx_records(domain)
|
||||||
map = EmailHelper.provider_outbound_mx(user, email, password, mx_domains)
|
map = EmailHelper.provider_outbound_mx(user, email, password, mx_domains)
|
||||||
|
|
||||||
assert_equal('smtp', map[0][:adapter])
|
assert_equal('smtp', map[0][:adapter])
|
||||||
assert_equal('arber.znuny.com', map[0][:options][:host])
|
assert_equal('mx2.zammad.com', map[0][:options][:host])
|
||||||
assert_equal(25, map[0][:options][:port])
|
assert_equal(25, map[0][:options][:port])
|
||||||
assert_equal(true, map[0][:options][:start_tls])
|
assert_equal(true, map[0][:options][:start_tls])
|
||||||
assert_equal(user, map[0][:options][:user])
|
assert_equal(user, map[0][:options][:user])
|
||||||
assert_equal(password, map[0][:options][:password])
|
assert_equal(password, map[0][:options][:password])
|
||||||
|
|
||||||
assert_equal('smtp', map[1][:adapter])
|
assert_equal('smtp', map[1][:adapter])
|
||||||
assert_equal('arber.znuny.com', map[1][:options][:host])
|
assert_equal('mx2.zammad.com', map[1][:options][:host])
|
||||||
assert_equal(25, map[1][:options][:port])
|
assert_equal(25, map[1][:options][:port])
|
||||||
assert_equal(true, map[1][:options][:start_tls])
|
assert_equal(true, map[1][:options][:start_tls])
|
||||||
assert_equal(email, map[1][:options][:user])
|
assert_equal(email, map[1][:options][:user])
|
||||||
|
@ -115,20 +115,20 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
test 'provider_outbound_guess' do
|
test 'provider_outbound_guess' do
|
||||||
|
|
||||||
email = 'linus@znuny.com'
|
email = 'linus@zammad.com'
|
||||||
password = 'some_pw'
|
password = 'some_pw'
|
||||||
user, domain = EmailHelper.parse_email(email)
|
user, domain = EmailHelper.parse_email(email)
|
||||||
map = EmailHelper.provider_outbound_guess(user, email, password, domain)
|
map = EmailHelper.provider_outbound_guess(user, email, password, domain)
|
||||||
|
|
||||||
assert_equal('smtp', map[0][:adapter])
|
assert_equal('smtp', map[0][:adapter])
|
||||||
assert_equal('mail.znuny.com', map[0][:options][:host])
|
assert_equal('mail.zammad.com', map[0][:options][:host])
|
||||||
assert_equal(25, map[0][:options][:port])
|
assert_equal(25, map[0][:options][:port])
|
||||||
assert_equal(true, map[0][:options][:start_tls])
|
assert_equal(true, map[0][:options][:start_tls])
|
||||||
assert_equal(user, map[0][:options][:user])
|
assert_equal(user, map[0][:options][:user])
|
||||||
assert_equal(password, map[0][:options][:password])
|
assert_equal(password, map[0][:options][:password])
|
||||||
|
|
||||||
assert_equal('smtp', map[1][:adapter])
|
assert_equal('smtp', map[1][:adapter])
|
||||||
assert_equal('mail.znuny.com', map[1][:options][:host])
|
assert_equal('mail.zammad.com', map[1][:options][:host])
|
||||||
assert_equal(25, map[1][:options][:port])
|
assert_equal(25, map[1][:options][:port])
|
||||||
assert_equal(true, map[1][:options][:start_tls])
|
assert_equal(true, map[1][:options][:start_tls])
|
||||||
assert_equal(email, map[1][:options][:user])
|
assert_equal(email, map[1][:options][:user])
|
||||||
|
@ -236,7 +236,7 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
result = EmailHelper::Probe.inbound(
|
result = EmailHelper::Probe.inbound(
|
||||||
adapter: 'imap',
|
adapter: 'imap',
|
||||||
options: {
|
options: {
|
||||||
host: 'arber.znuny.com',
|
host: 'mx2.zammad.com',
|
||||||
port: 993,
|
port: 993,
|
||||||
ssl: true,
|
ssl: true,
|
||||||
user: 'some@example.com',
|
user: 'some@example.com',
|
||||||
|
@ -245,23 +245,22 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
assert_equal('invalid', result[:result])
|
assert_equal('invalid', result[:result])
|
||||||
assert_equal('Authentication failed!', result[:message_human])
|
assert_equal('Authentication failed!', result[:message_human])
|
||||||
assert_equal('arber.znuny.com', result[:settings][:options][:host])
|
assert_equal('mx2.zammad.com', result[:settings][:options][:host])
|
||||||
|
|
||||||
# realtest - test I
|
# realtest - test I
|
||||||
if !ENV['EMAILHELPER_MAILBOX_1']
|
if !ENV['EMAILHELPER_MAILBOX_1']
|
||||||
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@zammad.com:somepass'"
|
||||||
end
|
end
|
||||||
|
|
||||||
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
||||||
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
||||||
user, _domain = EmailHelper.parse_email(mailbox_user)
|
|
||||||
result = EmailHelper::Probe.inbound(
|
result = EmailHelper::Probe.inbound(
|
||||||
adapter: 'imap',
|
adapter: 'imap',
|
||||||
options: {
|
options: {
|
||||||
host: 'arber.znuny.com',
|
host: 'mx2.zammad.com',
|
||||||
port: 993,
|
port: 993,
|
||||||
ssl: true,
|
ssl: true,
|
||||||
user: user,
|
user: mailbox_user,
|
||||||
password: mailbox_password,
|
password: mailbox_password,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -388,36 +387,33 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
{
|
{
|
||||||
adapter: 'smtp',
|
adapter: 'smtp',
|
||||||
options: {
|
options: {
|
||||||
host: 'arber.znuny.com',
|
host: 'mx2.zammad.com',
|
||||||
port: 25,
|
port: 587,
|
||||||
start_tls: true,
|
user: 'some@example.com',
|
||||||
user: 'some@example.com',
|
password: 'password',
|
||||||
password: 'password',
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'some@example.com',
|
'some@example.com',
|
||||||
)
|
)
|
||||||
assert_equal('invalid', result[:result])
|
assert_equal('invalid', result[:result])
|
||||||
assert_equal('Authentication failed!', result[:message_human])
|
assert_equal('Authentication failed!', result[:message_human])
|
||||||
assert_equal('arber.znuny.com', result[:settings][:options][:host])
|
assert_equal('mx2.zammad.com', result[:settings][:options][:host])
|
||||||
|
|
||||||
# realtest - test I
|
# realtest - test I
|
||||||
if !ENV['EMAILHELPER_MAILBOX_1']
|
if !ENV['EMAILHELPER_MAILBOX_1']
|
||||||
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@zammad.com:somepass'"
|
||||||
end
|
end
|
||||||
|
|
||||||
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
||||||
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
||||||
user, _domain = EmailHelper.parse_email(mailbox_user)
|
|
||||||
result = EmailHelper::Probe.outbound(
|
result = EmailHelper::Probe.outbound(
|
||||||
{
|
{
|
||||||
adapter: 'smtp',
|
adapter: 'smtp',
|
||||||
options: {
|
options: {
|
||||||
host: 'arber.znuny.com',
|
host: 'mx2.zammad.com',
|
||||||
port: 25,
|
port: 587,
|
||||||
start_tls: true,
|
user: mailbox_user,
|
||||||
user: user,
|
password: mailbox_password,
|
||||||
password: mailbox_password,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mailbox_user,
|
mailbox_user,
|
||||||
|
@ -436,7 +432,7 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# realtest - test I, with imap
|
# realtest - test I, with imap
|
||||||
if !ENV['EMAILHELPER_MAILBOX_1']
|
if !ENV['EMAILHELPER_MAILBOX_1']
|
||||||
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@zammad.com:somepass'"
|
||||||
end
|
end
|
||||||
|
|
||||||
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
||||||
|
@ -447,8 +443,8 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
password: mailbox_password,
|
password: mailbox_password,
|
||||||
)
|
)
|
||||||
assert_equal('ok', result[:result])
|
assert_equal('ok', result[:result])
|
||||||
assert_equal('arber.znuny.com', result[:setting][:inbound][:options][:host])
|
assert_equal('mx2.zammad.com', result[:setting][:inbound][:options][:host])
|
||||||
assert_equal('arber.znuny.com', result[:setting][:outbound][:options][:host])
|
assert_equal('mx2.zammad.com', result[:setting][:outbound][:options][:host])
|
||||||
|
|
||||||
# realtest - test II, gmail with only pop3
|
# realtest - test II, gmail with only pop3
|
||||||
if !ENV['EMAILHELPER_MAILBOX_2']
|
if !ENV['EMAILHELPER_MAILBOX_2']
|
||||||
|
@ -473,31 +469,29 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# realtest - test I, with imap
|
# realtest - test I, with imap
|
||||||
if !ENV['EMAILHELPER_MAILBOX_1']
|
if !ENV['EMAILHELPER_MAILBOX_1']
|
||||||
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@zammad.com:somepass'"
|
||||||
end
|
end
|
||||||
|
|
||||||
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
||||||
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
||||||
user, _domain = EmailHelper.parse_email(mailbox_user)
|
|
||||||
result = EmailHelper::Verify.email(
|
result = EmailHelper::Verify.email(
|
||||||
inbound: {
|
inbound: {
|
||||||
adapter: 'imap',
|
adapter: 'imap',
|
||||||
options: {
|
options: {
|
||||||
host: 'arber.znuny.com',
|
host: 'mx2.zammad.com',
|
||||||
port: 993,
|
port: 993,
|
||||||
ssl: true,
|
ssl: true,
|
||||||
user: user,
|
user: mailbox_user,
|
||||||
password: mailbox_password,
|
password: mailbox_password,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
outbound: {
|
outbound: {
|
||||||
adapter: 'smtp',
|
adapter: 'smtp',
|
||||||
options: {
|
options: {
|
||||||
host: 'arber.znuny.com',
|
host: 'mx2.zammad.com',
|
||||||
port: 25,
|
port: 587,
|
||||||
start_tls: true,
|
user: mailbox_user,
|
||||||
user: user,
|
password: mailbox_password,
|
||||||
password: mailbox_password,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sender: mailbox_user,
|
sender: mailbox_user,
|
||||||
|
|
Loading…
Reference in a new issue