Merge branch 'develop' of github.com:martini/zammad into develop

This commit is contained in:
Felix Niklas 2016-01-13 18:50:36 +01:00
commit 84a08c4a69
4 changed files with 61 additions and 27 deletions

View file

@ -18,6 +18,12 @@ class Index extends App.ControllerContent
@fetch()
@bind('import:finished', =>
console.log('import:finished')
@Config.set('system_init_done', true)
@navigate '#'
)
fetch: ->
# get data
@ -79,7 +85,6 @@ class Index extends App.ControllerContent
success: (data, status, xhr) =>
# validate form
console.log(data)
if data.result is 'ok'
@urlStatus.attr('data-state', 'success')
@linkErrorMessage.text('')
@ -103,7 +108,6 @@ class Index extends App.ControllerContent
success: (data, status, xhr) =>
# validate form
console.log(data)
if data.result is 'ok'
@delay( @updateMigration, 3000 )
)

View file

@ -22,9 +22,7 @@ class ImportOtrsController < ApplicationController
'Connection refused' => 'Connection refused!',
}
url_parts = params[:url].split(';')
response = UserAgent.request( url_parts[0] )
response = UserAgent.request( params[:url] )
if !response.success? && response.code.to_s !~ /^40.$/
message_human = ''
@ -44,16 +42,27 @@ class ImportOtrsController < ApplicationController
result = {}
if response.body =~ /zammad migrator/
key_parts = url_parts[1].split('=')
migrator_response = JSON.parse(response.body)
Setting.set('import_backend', 'otrs')
Setting.set('import_otrs_endpoint', url_parts[0])
Setting.set('import_otrs_endpoint_key', key_parts[1])
if migrator_response['Success'] == 1
result = {
result: 'ok',
url: params[:url],
}
url_parts = params[:url].split(';')
key_parts = url_parts[1].split('=')
Setting.set('import_backend', 'otrs')
Setting.set('import_otrs_endpoint', url_parts[0])
Setting.set('import_otrs_endpoint_key', key_parts[1])
result = {
result: 'ok',
url: params[:url],
}
else
result = {
result: 'invalid',
message_human: migrator_response['Error']
}
end
elsif response.body =~ /(otrs\sag|otrs\.com|otrs\.org)/i
result = {
result: 'invalid',

View file

@ -412,6 +412,11 @@ module Import::OTRS
Setting.set('system_init_done', true)
Setting.set('import_mode', false)
# broadcast import finish
Sessions.broadcast(
event: 'import:finished',
)
true
end

View file

@ -11,8 +11,6 @@ class OtrsImportBrowserTest < TestCase
fail "ERROR: Need IMPORT_BT_OTRS_ENDPOINT_KEY - hint IMPORT_BT_OTRS_ENDPOINT_KEY='01234567899876543210'"
end
import_url = "#{ENV['IMPORT_BT_OTRS_ENDPOINT']};Key=#{ENV['IMPORT_BT_OTRS_ENDPOINT_KEY']}"
@browser = browser_instance
location(url: browser_url)
@ -20,26 +18,44 @@ class OtrsImportBrowserTest < TestCase
click(css: 'a[href="#import/otrs"]')
click(css: '.js-download')
click(css: '.js-otrs-link')
invalid_key_url = "#{ENV['IMPORT_BT_OTRS_ENDPOINT']};Key=31337"
set(
css: '#otrs-link',
value: invalid_key_url
)
sleep 5
watch_for(
css: '.otrs-link-error',
value: 'Invalid API key.',
)
import_url = "#{ENV['IMPORT_BT_OTRS_ENDPOINT']};Key=#{ENV['IMPORT_BT_OTRS_ENDPOINT_KEY']}"
set(
css: '#otrs-link',
value: import_url
)
watch_for(
css: 'body',
value: 'xxxx',
timeout: 10,
sleep 5
watch_for_disappear(
css: '.otrs-link-error',
value: 'Invalid API key.',
)
# click import
click(css: '.js-migration-start')
# click otrs
# enter otrs url + key
# watch for import start
# watch for import end
watch_for(
css: 'body',
value: 'login',
timeout: 300,
)
end