Some small setup improvements.

This commit is contained in:
Martin Edenhofer 2014-11-18 22:09:01 +01:00
parent 006e28d95b
commit 7e9f246ee7
7 changed files with 304 additions and 54 deletions

View file

@ -221,6 +221,7 @@ class Base extends App.ControllerContent
url: url
organization: organization
)
@$("input, select").first().focus()
onLogoPick: (event) =>
reader = new FileReader()
@ -352,6 +353,7 @@ class ChannelEmail extends App.ControllerContent
'submit .js-inbound': 'probeInbound'
'change .js-outbound [name=adapter]': 'toggleOutboundAdapter'
'submit .js-outbound': 'probleOutbound'
'click .js-back': 'goToSlide'
constructor: ->
super
@ -397,6 +399,7 @@ class ChannelEmail extends App.ControllerContent
render: ->
@html App.view('getting_started/email')()
@showSlide('js-intro')
# outbound
adapters =
@ -414,11 +417,10 @@ class ChannelEmail extends App.ControllerContent
# inbound
configureAttributesInbound = [
{ name: 'adapter', display: 'Type', tag: 'select', multiple: false, null: false, options: { imap: 'IMAP', pop3: 'POP3' } },
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false },
{ name: 'options::ssl', display: 'SSL', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' }, translate: true, default: true},
{ name: 'adapter', display: 'Type', tag: 'select', multiple: false, null: false, options: { imap: 'IMAP', pop3: 'POP3' } },
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: false, autocapitalize: false, single: true },
]
new App.ControllerForm(
el: @$('.base-inbound-settings'),
@ -437,11 +439,9 @@ class ChannelEmail extends App.ControllerContent
adapter = @$('.js-outbound [name=adapter]').val()
if adapter is 'smtp'
configureAttributesOutbound = [
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false, default: (channel_used['options']&&channel_used['options']['host']) },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false, default: (channel_used['options']&&channel_used['options']['user']) },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false, default: (channel_used['options']&&channel_used['options']['password']) },
{ name: 'options::ssl', display: 'SSL', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' } , translate: true, default: (channel_used['options']&&channel_used['options']['ssl']||true) },
{ name: 'options::port', display: 'Port', tag: 'input', type: 'text', limit: 5, null: false, class: 'span1', autocapitalize: false, default: ((channel_used['options']&&channel_used['options']['port']) || 25) },
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false, autofocus: true, default: (channel_used['options']&&channel_used['options']['host']) },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false, default: (channel_used['options']&&channel_used['options']['user']) },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: true, autocapitalize: false, single: true, default: (channel_used['options']&&channel_used['options']['password']) },
]
@form = new App.ControllerForm(
el: @$('.base-outbound-settings')
@ -492,6 +492,8 @@ class ChannelEmail extends App.ControllerContent
params = @formParam(e.target)
@disable(e)
@showSlide('js-test')
@ajax(
id: 'email_inbound'
type: 'POST'
@ -509,9 +511,12 @@ class ChannelEmail extends App.ControllerContent
@$('.js-outbound [name="options::password"]').val( @account['meta']['password'] )
else
@showSlide('js-inbound')
@showAlert('js-inbound', data.message_human || data.message )
@enable(e)
fail: =>
@showSlide('js-inbound')
@showAlert('js-inbound', data.message_human || data.message )
@enable(e)
)
@ -523,6 +528,8 @@ class ChannelEmail extends App.ControllerContent
params['email'] = @account['meta']['email']
@disable(e)
@showSlide('js-test')
@ajax(
id: 'email_outbound'
type: 'POST'
@ -537,9 +544,12 @@ class ChannelEmail extends App.ControllerContent
@verify(@account)
else
@showSlide('js-outbound')
@showAlert('js-outbound', data.message_human || data.message )
@enable(e)
fail: =>
@showSlide('js-outbound')
@showAlert('js-outbound', data.message_human || data.message )
@enable(e)
)
@ -566,20 +576,24 @@ class ChannelEmail extends App.ControllerContent
2300
)
else
console.log('r', data, @account)
if data.subject && @account
@account.subject = data.subject
@verify( @account, count + 1 )
#@enable(e)
fail: =>
#@enable(e)
@showSlide('js-intro')
@showAlert('js-intro', 'Unable to verify sending and receiving. Please check your settings.' )
)
goToSlide: (e) =>
e.preventDefault()
slide = $(e.target).data('slide')
@showSlide(slide)
showSlide: (name) =>
@hideAlert(name)
@$('.setup.wizard').addClass('hide')
@$(".setup.wizard.#{name}").removeClass('hide')
@$(".setup.wizard.#{name} input, .setup.wizard.#{name} select").first().focus()
showAlert: (screen, message) =>
@$(".#{screen}").find('.alert').removeClass('hide').text( App.i18n.translateInline( message ) )

View file

@ -9,15 +9,15 @@
<fieldset>
<div class="form-group">
<label><%- @T('Full Name') %></label>
<input type="text" class="form-control" value="" name="realname" placeholder="<%- @T('Organization Support') %>">
<input type="text" class="form-control" value="" name="realname" placeholder="<%- @T('Organization Support') %>" required>
</div>
<div class="form-group">
<label><%- @T('Email') %></label>
<input type="email" class="form-control" value="" name="email" placeholder="<%- @T('support@example.com') %>">
<input type="email" class="form-control" value="" name="email" placeholder="<%- @T('support@example.com') %>" required>
</div>
<div class="form-group">
<label><%- @T('Password') %></label>
<input type="password" class="form-control" name="password" value="">
<input type="password" class="form-control" name="password" value="" required>
</div>
</fieldset>
</div>
@ -39,6 +39,17 @@
</div>
</form>
<form class="setup wizard hide js-test">
<div class="wizard-slide">
<h2><%- @T('Email Account') %></h2>
<div class="wizard-body vertical justified">
<p class="wizard-loadingText">
<span class="loading icon"></span> <%- @T('Verifying...') %>
</p>
</div>
</div>
</form>
<form class="setup wizard hide js-verify">
<div class="wizard-slide">
<h2><%- @T('Email Account') %></h2>
@ -59,7 +70,7 @@
<div class="base-inbound-settings"></div>
</div>
<div class="wizard-controls center">
<a class="subtle-link" href="#getting_started/channel"><%- @T('Go Back') %></a>
<a class="subtle-link js-back" data-slide="js-intro"><%- @T('Go Back') %></a>
<button class="btn btn--primary align-right"><%- @T( 'Continue' ) %></button>
</div>
</div>
@ -74,7 +85,7 @@
<div class="base-outbound-settings"></div>
</div>
<div class="wizard-controls center">
<a class="subtle-link" href="#getting_started/channel"><%- @T('Go Back') %></a>
<a class="subtle-link js-back" data-slide="js-inbound"><%- @T('Go Back') %></a>
<button class="btn btn--primary align-right"><%- @T( 'Continue' ) %></button>
</div>
</div>

View file

@ -187,7 +187,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
domains = [domain]
mail_exchangers = mxers(domain)
if mail_exchangers && mail_exchangers[0]
puts "MX #{mail_exchangers} - #{mail_exchangers[0][0]}"
logger.info "MX for #{domain}: #{mail_exchangers} - #{mail_exchangers[0][0]}"
end
if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
domains.push mail_exchangers[0][0]
@ -352,9 +352,9 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
settings = {}
success = false
inboundMap.each {|config|
puts "PROBE: #{config.inspect}"
logger.info "INBOUND PROBE: #{config.inspect}"
result = email_probe_inbound( config )
puts "RESULT: #{result.inspect}"
logger.info "INBOUND RESULT: #{result.inspect}"
if result[:result] == 'ok'
success = true
settings[:inbound] = config
@ -501,9 +501,9 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
success = false
outboundMap.each {|config|
puts "PROBE: #{config.inspect}"
logger.info "OUTBOUND PROBE: #{config.inspect}"
result = email_probe_outbound( config, params[:email] )
puts "RESULT: #{result.inspect}"
logger.info "OUTBOUND RESULT: #{result.inspect}"
if result[:result] == 'ok'
success = true
settings[:outbound] = config
@ -576,15 +576,25 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
result = email_probe_outbound( params[:outbound], params[:meta][:email], subject )
(1..7).each {|loop|
sleep 7
(1..5).each {|loop|
sleep 10
# fetch mailbox
found = nil
if params[:inbound][:adapter] =~ /^imap$/i
found = Channel::IMAP.new.fetch( { :options => params[:inbound][:options] }, 'verify', subject )
else
found = Channel::POP3.new.fetch( { :options => params[:inbound][:options] }, 'verify', subject )
begin
if params[:inbound][:adapter] =~ /^imap$/i
found = Channel::IMAP.new.fetch( { :options => params[:inbound][:options] }, 'verify', subject )
else
found = Channel::POP3.new.fetch( { :options => params[:inbound][:options] }, 'verify', subject )
end
rescue Exception => e
render :json => {
:result => 'invalid',
:message => e.to_s,
:subject => subject,
}
return
end
if found && found == 'verify ok'
@ -646,7 +656,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
}
# check dilivery for 30 sek.
# check delivery for 30 sek.
render :json => {
:result => 'invalid',
:message => 'Verification Email not found in mailbox.',
@ -687,11 +697,21 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# test connection
translationMap = {
'authentication failed' => 'Authentication failed!',
'Incorrect username' => 'Authentication failed!',
'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!',
'No route to host' => 'No route to host!',
'Connection refused' => 'Connection refused!',
}
if params[:adapter] =~ /^smtp$/i
# in case, fill missing params
if !params[:options].has_key?(:port)
params[:options][:port] = 25
end
if !params[:options].has_key?(:ssl)
params[:options][:ssl] = true
end
begin
Channel::SMTP.new.send(
mail,
@ -773,11 +793,13 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# connection test
translationMap = {
'authentication failed' => 'Authentication failed!',
'Incorrect username' => 'Authentication failed!',
'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!',
'No route to host' => 'No route to host!',
'Connection refused' => 'Connection refused!',
}
if params[:adapter] =~ /^imap$/i
begin
Channel::IMAP.new.fetch( { :options => params[:options] }, 'check' )
rescue Exception => e

View file

@ -5,11 +5,11 @@ require 'net/imap'
class Channel::IMAP < Channel::EmailParser
def fetch (channel, check_type = '', verify_string = '')
ssl = false
port = 143
if channel[:options][:ssl].to_s == 'true'
ssl = true
port = 993
ssl = true
port = 993
if channel[:options].has_key?(:ssl) && channel[:options][:ssl].to_s == 'false'
ssl = false
port = 143
end
puts "fetching imap (#{channel[:options][:host]}/#{channel[:options][:user]} port=#{port},ssl=#{ssl})"
@ -26,15 +26,15 @@ class Channel::IMAP < Channel::EmailParser
end
# try LOGIN, if not - try plain
begin
@imap.authenticate( 'LOGIN', channel[:options][:user], channel[:options][:password] )
rescue Exception => e
if e.to_s !~ /unsupported\s(authenticate|authentication)\smechanism/i
raise e
end
@imap.login( channel[:options][:user], channel[:options][:password] )
# try LOGIN, if not - try plain
begin
@imap.authenticate( 'LOGIN', channel[:options][:user], channel[:options][:password] )
rescue Exception => e
if e.to_s !~ /unsupported\s(authenticate|authentication)\smechanism/i
raise e
end
@imap.login( channel[:options][:user], channel[:options][:password] )
end
if !channel[:options][:folder] || channel[:options][:folder].empty?
@imap.select('INBOX')

View file

@ -5,11 +5,11 @@ require 'net/pop'
class Channel::POP3 < Channel::EmailParser
def fetch (channel, check_type = '', verify_string = '')
ssl = false
port = 110
if channel[:options][:ssl].to_s == 'true'
ssl = true
port = 995
ssl = true
port = 995
if channel[:options].has_key?(:ssl) && channel[:options][:ssl].to_s == 'false'
ssl = false
port = 110
end
puts "fetching pop3 (#{channel[:options][:host]}/#{channel[:options][:user]} port=#{port},ssl=#{ssl})"

View file

@ -2,8 +2,13 @@
require 'browser_test_helper'
class AaaGettingStartedTest < TestCase
def test_getting_started
tests = [
def test_a_getting_started
if !ENV['MAILBOX_INIT']
raise "Need MAILBOX_INIT as ENV variable like export MAILBOX_INIT='unittest01@znuny.com:somepass'"
end
mailbox_user = ENV['MAILBOX_INIT'].split(':')[0]
mailbox_password = ENV['MAILBOX_INIT'].split(':')[1]
tests = [
{
:name => 'start',
:instance => browser_instance,
@ -138,12 +143,12 @@ class AaaGettingStartedTest < TestCase
{
:execute => 'set',
:css => '.js-intro input[name="email"]',
:value => 'otest01@znuny.com',
:value => mailbox_user,
},
{
:execute => 'set',
:css => '.js-intro input[name="password"]',
:value => 'otest0142',
:value => mailbox_password,
},
{
:execute => 'click',
@ -153,16 +158,19 @@ class AaaGettingStartedTest < TestCase
:execute => 'watch_for',
:area => 'body',
:value => 'testing',
:timeout => 60,
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'verify',
:timeout => 70,
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'invite',
:timeout => 60,
},
{
:execute => 'check',
@ -234,4 +242,199 @@ class AaaGettingStartedTest < TestCase
]
browser_single_test(tests)
end
def test_b_accounts_auto
if !ENV['MAILBOX_AUTO1']
raise "Need MAILBOX_AUTO1 as ENV variable like export MAILBOX_AUTO1='nicole.braun2015@gmail.com:somepass'"
end
mailbox_user = ENV['MAILBOX_AUTO1'].split(':')[0]
mailbox_password = ENV['MAILBOX_AUTO1'].split(':')[1]
accounts = [
{
:realname => 'gmail',
:email => mailbox_user,
:password => mailbox_password,
},
]
accounts.each {|account|
tests = [
{
:name => 'getting started - auto mail',
:action => [
{
:execute => 'navigate',
:to => browser_url + '/#getting_started/channel',
},
{
:execute => 'click',
:css => '.js-channel .email .provider_name',
},
{
:execute => 'set',
:css => '.js-intro input[name="realname"]',
:value => account[:realname],
},
{
:execute => 'set',
:css => '.js-intro input[name="email"]',
:value => account[:email],
},
{
:execute => 'set',
:css => '.js-intro input[name="password"]',
:value => account[:password],
},
{
:execute => 'click',
:css => '.js-intro .btn--primary',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'testing',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'verify',
:timeout => 80,
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'invite',
},
{
:execute => 'check',
:element => :url,
:result => '#getting_started/agents',
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'master@example.com' })
}
end
def test_b_accounts_manual
if !ENV['MAILBOX_MANUAL1']
raise "Need MAILBOX_AUTO1 as ENV variable like export MAILBOX_MANUAL1='nicole.bauer2015@yahoo.de:somepass:imap.mail.yahoo.com:smtp.mail.yahoo.com'"
end
mailbox_user = ENV['MAILBOX_MANUAL1'].split(':')[0]
mailbox_password = ENV['MAILBOX_MANUAL1'].split(':')[1]
mailbox_inbound = ENV['MAILBOX_MANUAL1'].split(':')[2]
mailbox_outbound = ENV['MAILBOX_MANUAL1'].split(':')[3]
accounts = [
{
:realname => 'yahoo',
:email => mailbox_user,
:password => mailbox_password,
:inbound => {
'options::host' => mailbox_inbound,
},
:outbound => {
'options::host' => mailbox_outbound,
},
},
]
accounts.each {|account|
tests = [
{
:name => 'getting started - manual mail',
:action => [
{
:execute => 'navigate',
:to => browser_url + '/#getting_started/channel',
},
{
:execute => 'click',
:css => '.js-channel .email .provider_name',
},
{
:execute => 'set',
:css => '.js-intro input[name="realname"]',
:value => account[:realname],
},
{
:execute => 'set',
:css => '.js-intro input[name="email"]',
:value => account[:email],
},
{
:execute => 'set',
:css => '.js-intro input[name="password"]',
:value => account[:password],
},
{
:execute => 'click',
:css => '.js-intro .btn--primary',
},
{
:execute => 'watch_for',
:area => '.js-probe',
:value => 'testing',
},
{
:execute => 'watch_for',
:area => '.js-inbound h2',
:value => 'inbound',
:timeout => 220,
},
{
:execute => 'watch_for',
:area => '.js-inbound',
:value => 'manual',
},
{
:execute => 'set',
:css => '.js-inbound input[name="options::host"]',
:value => account[:inbound]['options::host'],
},
{
:execute => 'click',
:css => '.js-inbound .btn--primary',
},
{
:execute => 'watch_for',
:area => '.js-outbound h2',
:value => 'outbound',
},
{
:execute => 'select',
:css => '.js-outbound select[name="adapter"]',
:value => 'SMTP - configure your own outgoing SMTP settings',
},
{
:execute => 'set',
:css => '.js-outbound input[name="options::host"]',
:value => account[:outbound]['options::host'],
},
{
:execute => 'click',
:css => '.js-outbound .btn--primary',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'verify',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'invite',
:timeout => 190,
},
{
:execute => 'check',
:element => :url,
:result => '#getting_started/agents',
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'master@example.com' })
}
end
end

View file

@ -254,7 +254,7 @@ class TestCase < Test::Unit::TestCase
if action[:timeout]
timeout = action[:timeout]
end
loops = timeout / 0.33
loops = (timeout / 0.5).to_i
text = ''
(1..loops).each { |loop|
element = instance.find_element( { :css => action[:area] } )
@ -266,7 +266,7 @@ class TestCase < Test::Unit::TestCase
return
end
end
sleep 0.33
sleep 0.5
}
assert( false, "(#{test[:name]}) '#{action[:value]}' found in '#{text}'" )
return