Browse Source

Maintenance: Port otrs_import_test.rb to rspec.

Martin Gruner 2 years ago
parent
commit
c40af71e8a

+ 29 - 92
.gitlab/ci/test/integration/otrs.yml

@@ -2,117 +2,54 @@
   extends:
     - .template_integration
   script:
-    - !reference [.scripts, zammad_db_unseeded]
-    - bundle exec rails test test/integration/otrs_import_test.rb
+    - !reference [.scripts, zammad_db_init]
+    - bundle exec rspec spec/integration/otrs_spec.rb
+  services:
+    - !reference [.services, mysql]
+    - !reference [.services, postgresql]
+    - !reference [.services, redis]
+    - !reference [.services, memcached]
+    - name: $CI_REGISTRY/docker/zammad-ci-otrsimport-db:$OTRS_CONTAINER_TAG
+      alias: zammad-ci-otrsimport-db
+    - name: $CI_REGISTRY/docker/zammad-ci-otrsimport-app:$OTRS_CONTAINER_TAG
+      alias: zammad-ci-otrsimport-app
   variables:
     FF_NETWORK_PER_BUILD: 1 # https://docs.gitlab.com/runner/configuration/feature-flags.html
     IMPORT_OTRS_ENDPOINT: 'http://zammad-ci-otrsimport-app/otrs/public.pl?Action=ZammadMigrator'
     TZ: 'Europe/Berlin' # Required for the zammad-ci-otrsimport-app containers
 
-minitest:integration:otrs:6:
+rspec:integration:otrs:6:
   extends:
     - .template_integration_otrs
-  services:
-    - name: $CI_REGISTRY/docker/zammad-mysql:stable
-      alias: mysql
-    - name: $CI_REGISTRY/docker/zammad-postgresql:stable
-      alias: postgresql
-    - name: $CI_REGISTRY/docker/zammad-redis:stable
-      alias: redis
-    - name: $CI_REGISTRY/docker/zammad-memcached:stable
-      alias: memcached
-      command: ['memcached', '-m', '256M']
-    - name: $CI_REGISTRY/docker/zammad-ci-otrsimport-db:otrs6
-      alias: zammad-ci-otrsimport-db
-    - name: $CI_REGISTRY/docker/zammad-ci-otrsimport-app:otrs6
-      alias: zammad-ci-otrsimport-app
+  variables:
+    OTRS_CONTAINER_TAG: 'otrs6'
 
-minitest:integration:otrs:5:
+rspec:integration:otrs:5:
   extends:
     - .template_integration_otrs
-  services:
-    - name: $CI_REGISTRY/docker/zammad-mysql:stable
-      alias: mysql
-    - name: $CI_REGISTRY/docker/zammad-postgresql:stable
-      alias: postgresql
-    - name: $CI_REGISTRY/docker/zammad-redis:stable
-      alias: redis
-    - name: $CI_REGISTRY/docker/zammad-memcached:stable
-      alias: memcached
-      command: ['memcached', '-m', '256M']
-    - name: $CI_REGISTRY/docker/zammad-ci-otrsimport-db:otrs5
-      alias: zammad-ci-otrsimport-db
-    - name: $CI_REGISTRY/docker/zammad-ci-otrsimport-app:otrs5
-      alias: zammad-ci-otrsimport-app
+  variables:
+    OTRS_CONTAINER_TAG: 'otrs5'
 
-minitest:integration:otrs:4:
+rspec:integration:otrs:4:
   extends:
     - .template_integration_otrs
-  services:
-    - name: $CI_REGISTRY/docker/zammad-mysql:stable
-      alias: mysql
-    - name: $CI_REGISTRY/docker/zammad-postgresql:stable
-      alias: postgresql
-    - name: $CI_REGISTRY/docker/zammad-redis:stable
-      alias: redis
-    - name: $CI_REGISTRY/docker/zammad-memcached:stable
-      alias: memcached
-      command: ['memcached', '-m', '256M']
-    - name: $CI_REGISTRY/docker/zammad-ci-otrsimport-db:otrs4
-      alias: zammad-ci-otrsimport-db
-    - name: $CI_REGISTRY/docker/zammad-ci-otrsimport-app:otrs4
-      alias: zammad-ci-otrsimport-app
+  variables:
+    OTRS_CONTAINER_TAG: 'otrs4'
 
-minitest:integration:otrs:33:
+rspec:integration:otrs:33:
   extends:
     - .template_integration_otrs
-  services:
-    - name: $CI_REGISTRY/docker/zammad-mysql:stable
-      alias: mysql
-    - name: $CI_REGISTRY/docker/zammad-postgresql:stable
-      alias: postgresql
-    - name: $CI_REGISTRY/docker/zammad-redis:stable
-      alias: redis
-    - name: $CI_REGISTRY/docker/zammad-memcached:stable
-      alias: memcached
-      command: ['memcached', '-m', '256M']
-    - name: $CI_REGISTRY/docker/zammad-ci-otrsimport-db:otrs33
-      alias: zammad-ci-otrsimport-db
-    - name: $CI_REGISTRY/docker/zammad-ci-otrsimport-app:otrs33
-      alias: zammad-ci-otrsimport-app
+  variables:
+    OTRS_CONTAINER_TAG: 'otrs33'
 
-minitest:integration:otrs:32:
+rspec:integration:otrs:32:
   extends:
     - .template_integration_otrs
-  services:
-    - name: $CI_REGISTRY/docker/zammad-mysql:stable
-      alias: mysql
-    - name: $CI_REGISTRY/docker/zammad-postgresql:stable
-      alias: postgresql
-    - name: $CI_REGISTRY/docker/zammad-redis:stable
-      alias: redis
-    - name: $CI_REGISTRY/docker/zammad-memcached:stable
-      alias: memcached
-      command: ['memcached', '-m', '256M']
-    - name: $CI_REGISTRY/docker/zammad-ci-otrsimport-db:otrs32
-      alias: zammad-ci-otrsimport-db
-    - name: $CI_REGISTRY/docker/zammad-ci-otrsimport-app:otrs32
-      alias: zammad-ci-otrsimport-app
+  variables:
+    OTRS_CONTAINER_TAG: 'otrs32'
 
-minitest:integration:otrs:31:
+rspec:integration:otrs:31:
   extends:
     - .template_integration_otrs
-  services:
-    - name: $CI_REGISTRY/docker/zammad-mysql:stable
-      alias: mysql
-    - name: $CI_REGISTRY/docker/zammad-postgresql:stable
-      alias: postgresql
-    - name: $CI_REGISTRY/docker/zammad-redis:stable
-      alias: redis
-    - name: $CI_REGISTRY/docker/zammad-memcached:stable
-      alias: memcached
-      command: ['memcached', '-m', '256M']
-    - name: $CI_REGISTRY/docker/zammad-ci-otrsimport-db:otrs31
-      alias: zammad-ci-otrsimport-db
-    - name: $CI_REGISTRY/docker/zammad-ci-otrsimport-app:otrs31
-      alias: zammad-ci-otrsimport-app
+  variables:
+    OTRS_CONTAINER_TAG: 'otrs31'

+ 1 - 1
.gitlab/ci/test/rspec.yml

@@ -26,4 +26,4 @@ rspec:integration:
     - !reference [.services, memcached]
   script:
     - !reference [.scripts, zammad_db_init]
-    - bundle exec rspec --exclude-pattern "spec/system/**/*_spec.rb" -t integration --profile 10
+    - bundle exec rspec --exclude-pattern "spec/system/**/*_spec.rb" -t integration -t ~integration_standalone --profile 10

+ 2 - 0
.rubocop/todo.rspec.yml

@@ -197,6 +197,7 @@ RSpec/ExampleLength:
     - 'spec/db/migrate/object_manager_attribute_date_remove_future_past_spec.rb'
     - 'spec/db/migrate/rename_locale_on_users_spec.rb'
     - 'spec/integration/ldap_spec.rb'
+    - 'spec/integration/otrs_spec.rb'
     - 'spec/jobs/communicate_twitter_job_spec.rb'
     - 'spec/jobs/concerns/has_active_job_lock_spec.rb'
     - 'spec/jobs/migrate_ldap_samaccountname_to_uid_job/ldap_spec.rb'
@@ -459,6 +460,7 @@ RSpec/MultipleExpectations:
     - 'spec/db/migrate/object_manager_attribute_date_remove_future_past_spec.rb'
     - 'spec/db/migrate/rename_locale_on_users_spec.rb'
     - 'spec/integration/ldap_spec.rb'
+    - 'spec/integration/otrs_spec.rb'
     - 'spec/jobs/communicate_twitter_job_spec.rb'
     - 'spec/jobs/concerns/has_active_job_lock_spec.rb'
     - 'spec/jobs/migrate_ldap_samaccountname_to_uid_job/ldap_spec.rb'

+ 263 - 0
spec/integration/otrs_spec.rb

@@ -0,0 +1,263 @@
+# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
+
+require 'rails_helper'
+
+# Test a full OTRS import process against a system with known state and compare some expected results.
+
+RSpec.describe 'OTRS import', integration: true, integration_standalone: true, required_envs: %w[IMPORT_OTRS_ENDPOINT IMPORT_OTRS_ENDPOINT_KEY] do # rubocop:disable RSpec/DescribeClass
+
+  before :all do # rubocop:disable RSpec/BeforeAfterAll
+    Setting.set('import_otrs_endpoint', ENV['IMPORT_OTRS_ENDPOINT'])
+    Setting.set('import_otrs_endpoint_key', ENV['IMPORT_OTRS_ENDPOINT_KEY'])
+    Setting.set('import_mode', true)
+    Setting.set('system_init_done', false)
+
+    WebMock.disable!
+    Import::OTRS.start
+    WebMock.enable!
+  end
+
+  context 'when importing setting' do
+    let(:protocol) { ENV['IMPORT_OTRS_ENDPOINT'].start_with?('https') ? 'https' : 'http' }
+
+    it 'imports correctly' do
+      expect(Setting.get('system_id')).to be_truthy
+      expect(Setting.get('http_type')).to eq(protocol)
+      expect(Setting.get('organization')).to eq('Example Company')
+    end
+  end
+
+  context 'when importing dynamic fields' do
+    let(:local_objects) { ObjectManager::Attribute.list_full }
+    let(:object_attribute_names) do
+      local_objects.select do |local_object|
+        local_object[:object] == 'Ticket'
+      end.collect do |local_object|
+        local_object['name']
+      end
+    end
+    let(:expected_object_attribute_names) { %w[vertriebsweg te_test number sugar_crm_remote_no sugar_crm_company_selected_no sugar_crm_company_selection combine title itsm_criticality customer_id itsm_impact itsm_review_required itsm_decision_result organization_id itsm_repair_start_time itsm_recovery_start_time itsm_decision_date itsm_due_date topic_no open_exchange_ticket_number hostname ticket_free_key11 type ticket_free_text11 open_exchange_tn topic zarafa_tn group_id scom_hostname checkbox_example scom_uuid scom_state scom_service location owner_id department customer_location textfeld state_id pending_time priority_id tags] }
+
+    it 'imports correctly' do
+      expect(object_attribute_names).to eq(expected_object_attribute_names)
+    end
+  end
+
+  context 'when importing in general' do
+    it 'imports the right number of objects' do
+      expect(Ticket.count).to eq(603)
+      expect(Ticket::Article.count).to eq(3182)
+      expect(Store.count).to eq(274)
+      expect(Ticket::State.count).to eq(10)
+      expect(Group.count).to eq(24)
+    end
+  end
+
+  context 'when importing users' do
+    let(:role_admin)     { Role.where(name: 'Admin').first }
+    let(:role_agent)     { Role.where(name: 'Agent').first }
+    let(:role_customer)  { Role.where(name: 'Customer').first }
+    let(:user1)          { User.find(2) }
+    let(:user2)          { User.find(3) }
+    let(:user3)          { User.find(7) }
+    let(:user4)          { User.find(8) }
+    let(:group_dasa)     { Group.where(name: 'dasa').first }
+    let(:group_raw)      { Group.where(name: 'Raw').first }
+
+    it 'imports correctly' do
+
+      expect(user1).to have_attributes(
+        {
+          firstname: 'agent-1 firstname',
+          lastname:  'agent-1 lastname',
+          login:     'agent-1',
+          email:     'agent-1@example.com',
+          active:    true,
+        }
+      )
+
+      expect(user1.roles).to include(role_agent).and(not_include(role_admin, role_customer))
+      expect(user1.groups_access('full')).to include(group_raw).and(not_include(group_dasa))
+
+      expect(user2).to have_attributes(
+        {
+          firstname: 'agent-2 firstname äöüß',
+          lastname:  'agent-2 lastname äöüß',
+          login:     'agent-2',
+          email:     'agent-2@example.com',
+          active:    true,
+        }
+      )
+
+      expect(user2.roles).to include(role_agent, role_admin).and(not_include(role_customer))
+      expect(user2.groups_access('full')).to include(group_raw, group_dasa)
+
+      expect(user3).to have_attributes(
+        {
+          firstname: 'invalid',
+          lastname:  'invalid',
+          login:     'invalid',
+          email:     'invalid@example.com',
+          active:    false,
+        }
+      )
+
+      expect(user3.roles).to include(role_agent).and(not_include(role_admin, role_customer))
+      expect(user3.groups_access('full')).to not_include(group_raw, group_dasa)
+
+      expect(user4).to have_attributes(
+        {
+          firstname: 'invalid-temp',
+          lastname:  'invalid-temp',
+          login:     'invalid-temp',
+          active:    false,
+        }
+      )
+
+      expect(user4.roles).to include(role_agent).and(not_include(role_admin, role_customer))
+      expect(user4.groups_access('full')).to not_include(group_raw, group_dasa)
+    end
+  end
+
+  context 'when importing groups' do
+    let(:group1) { Group.find(1) }
+    let(:group2) { Group.find(19) }
+
+    it 'imports correctly' do
+      expect(group1).to have_attributes(
+        {
+          name:   'Postmaster',
+          active: true,
+        }
+      )
+      expect(group2).to have_attributes(
+        {
+          name:   'UnitTestQueue20668',
+          active: false,
+        }
+      )
+    end
+  end
+
+  context 'when importing customers / organizations' do
+    let(:user1) { User.where(login: 'jn').first }
+    let(:user2) { User.where(login: 'test90133').first }
+
+    it 'imports correctly' do
+      expect(user1).to have_attributes(
+        {
+          firstname: 'Johannes',
+          lastname:  'Nickel',
+          login:     'jn',
+          email:     'jn@example.com',
+        }
+      )
+      expect(user1.organization).to have_attributes(
+        {
+          name: 'Znuny GmbH Berlin',
+          note: 'äöüß',
+        }
+      )
+
+      expect(user2).to have_attributes(
+        {
+          firstname: 'test90133',
+          lastname:  'test90133',
+          login:     'test90133',
+          email:     'qa4711@t-online.de',
+        }
+      )
+      expect(user2.organization).to have_attributes(
+        {
+          name: 'test554449',
+          note: 'test554449',
+        }
+      )
+    end
+  end
+
+  context 'when importing ticket states' do
+    let(:new_state) { Ticket::State.find(1) }
+    let(:closed_state)  { Ticket::State.find(2) }
+    let(:pending_state) { Ticket::State.find(6) }
+
+    it 'imports correctly' do
+      expect(new_state.name).to eq('new')
+      expect(new_state.state_type.name).to eq('new')
+      expect(closed_state.name).to eq('closed successful')
+      expect(closed_state.state_type.name).to eq('closed')
+      expect(pending_state.name).to eq('pending reminder')
+      expect(pending_state.state_type.name).to eq('pending reminder')
+    end
+  end
+
+  context 'when importing tickets' do
+    let(:ticket1) { Ticket.find(728) }
+    let(:ticket2) { Ticket.find(729) }
+    let(:ticket3) { Ticket.find(730) }
+    let(:ticket4) { Ticket.find(591) }
+
+    it 'imports correctly' do
+      # ticket1 is open
+      expect(ticket1.title).to eq('test #1')
+      expect(ticket1.state.name).to eq('open')
+      expect(ticket1.group.name).to eq('Misc')
+      expect(ticket1.priority.name).to eq('4 high')
+      expect(ticket1.owner.login).to eq('agent-2')
+      expect(ticket1.customer.login).to eq('partner')
+      expect(ticket1.organization.name).to eq('Partner der betreut')
+      expect(ticket1.created_at.to_s).to eq(Time.zone.parse('2014-11-20 22:33:41 +0000').gmtime.to_s)
+      expect(ticket1.close_at).to be_nil
+
+      # ticket2 is created with state closed
+      expect(ticket2.title).to eq('test #2')
+      expect(ticket2.state.name).to eq('closed successful')
+      expect(ticket2.group.name).to eq('Raw')
+      expect(ticket2.priority.name).to eq('3 normal')
+      expect(ticket2.owner.login).to eq('agent-2')
+      expect(ticket2.customer.login).to eq('jn2')
+      expect(ticket2.organization.name).to eq('Znuny GmbH')
+      expect(ticket2.created_at.to_s).to eq(Time.zone.parse('2014-11-20 23:24:20 +0000').gmtime.to_s)
+      expect(ticket2.close_at.to_s).to eq(Time.zone.parse('2014-11-20 23:24:20 +0000').gmtime.to_s)
+
+      # ticket3 is created open and now closed
+      expect(ticket3.title).to eq('test #3')
+      expect(ticket3.state.name).to eq('closed successful')
+      expect(ticket3.group.name).to eq('Postmaster')
+      expect(ticket3.priority.name).to eq('3 normal')
+      expect(ticket3.owner.login).to eq('agent-2')
+      expect(ticket3.customer.login).to eq('betreuterkunde2')
+      expect(ticket3.organization.name).to eq('Noch ein betreuter Kunde')
+      expect(ticket3.created_at.to_s).to eq(Time.zone.parse('2014-11-21 00:17:40 +0000').gmtime.to_s)
+      expect(ticket3.close_at.to_s).to eq(Time.zone.parse('2014-11-21 00:21:08 +0000').gmtime.to_s)
+
+      # ticket dynamic fields
+      expect(ticket4.title).to eq('Some other smart subject!')
+      expect(ticket4.vertriebsweg).to eq('488')
+      expect(ticket4.te_test).to eq(%w[193 194])
+      expect(ticket4.sugar_crm_remote_no).to eq('358')
+      expect(ticket4.sugar_crm_company_selected_no).to eq('69')
+      expect(ticket4.sugar_crm_company_selection).to eq(['382'])
+      expect(ticket4.topic_no).to eq('310')
+      expect(ticket4.open_exchange_ticket_number).to eq('495')
+      expect(ticket4.hostname).to eq('208')
+    end
+  end
+
+  context 'when importing attachments' do
+    let(:article1) { Ticket::Article.find(149) }
+    let(:attachment1) { article1.attachments.first }
+    let(:article2)    { Ticket::Article.find(156) }
+    let(:attachment2) { article2.attachments.second }
+
+    it 'imports correctly' do
+      expect(article1.attachments.count).to eq(5)
+      expect(attachment1.preferences['Mime-Type']).to eq('image/jpeg')
+      expect(attachment1.filename).to eq('Cursor_und_Banners_and_Alerts_und_Paket-Verwaltung_-_Admin_-_otrs336_und_otrs336.jpg')
+
+      expect(article2.attachments.count).to eq(2)
+      expect(attachment2.preferences['Mime-Type']).to eq('application/pdf; name="=?UTF-8?B?5ZSQ6K+X5LiJ55m+6aaWLnBkZg==?="')
+      expect(attachment2.filename).to eq('唐诗三百首.pdf')
+    end
+  end
+end

+ 0 - 250
test/integration/otrs_import_test.rb

@@ -1,250 +0,0 @@
-# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
-
-require 'integration_test_helper'
-
-class OtrsImportTest < ActiveSupport::TestCase
-
-  if !ENV['IMPORT_OTRS_ENDPOINT']
-    raise "ERROR: Need IMPORT_OTRS_ENDPOINT - hint IMPORT_OTRS_ENDPOINT='http://vz305.demo.zammad.com/otrs/public.pl?Action=ZammadMigrator'"
-  end
-  if !ENV['IMPORT_OTRS_ENDPOINT_KEY']
-    raise "ERROR: Need IMPORT_OTRS_ENDPOINT_KEY - hint IMPORT_OTRS_ENDPOINT_KEY='01234567899876543210'"
-  end
-
-  Setting.set('import_otrs_endpoint', ENV['IMPORT_OTRS_ENDPOINT'])
-  Setting.set('import_otrs_endpoint_key', ENV['IMPORT_OTRS_ENDPOINT_KEY'])
-  Setting.set('import_mode', true)
-  Setting.set('system_init_done', false)
-  Import::OTRS.start
-
-  # check settings items
-  test 'check settings' do
-    http      = nil
-    if ENV['IMPORT_OTRS_ENDPOINT'] =~ %r{^(http|https)://}
-      http = $1
-    end
-    assert(Setting.get('system_id'), 'system_id')
-    assert_equal(http, Setting.get('http_type'), 'http_type')
-    assert_equal('Example Company', Setting.get('organization'), 'organization')
-  end
-
-  test 'check dynamic fields' do
-    local_objects = ObjectManager::Attribute.list_full
-
-    object_attribute_names = local_objects.select do |local_object|
-      local_object[:object] == 'Ticket'
-    end.collect do |local_object|
-      local_object['name']
-    end
-    expected_object_attribute_names = %w[vertriebsweg te_test number sugar_crm_remote_no sugar_crm_company_selected_no sugar_crm_company_selection combine title itsm_criticality customer_id itsm_impact itsm_review_required itsm_decision_result organization_id itsm_repair_start_time itsm_recovery_start_time itsm_decision_date itsm_due_date topic_no open_exchange_ticket_number hostname ticket_free_key11 type ticket_free_text11 open_exchange_tn topic zarafa_tn group_id scom_hostname checkbox_example scom_uuid scom_state scom_service location owner_id department customer_location textfeld state_id pending_time priority_id tags]
-
-    assert_equal(expected_object_attribute_names, object_attribute_names, 'dynamic field names')
-  end
-
-  # check count of imported items
-  test 'check counts' do
-    assert_equal(603, Ticket.count, 'tickets')
-    assert_equal(3182, Ticket::Article.count, 'ticket articles')
-    assert_equal(274, Store.count, 'ticket article attachments')
-    assert_equal(10, Ticket::State.count, 'ticket states')
-    assert_equal(24, Group.count, 'groups')
-  end
-
-  # check imported users and permission
-  test 'check users' do
-    role_admin    = Role.where(name: 'Admin').first
-    role_agent    = Role.where(name: 'Agent').first
-    role_customer = Role.where(name: 'Customer').first
-    # role_report   = Role.where( :name => 'Report' ).first
-
-    user1 = User.find(2)
-    assert_equal('agent-1 firstname', user1.firstname)
-    assert_equal('agent-1 lastname', user1.lastname)
-    assert_equal('agent-1', user1.login)
-    assert_equal('agent-1@example.com', user1.email)
-    assert_equal(true, user1.active)
-
-    assert(user1.roles.include?(role_agent))
-    assert_not(user1.roles.include?(role_admin))
-    assert_not(user1.roles.include?(role_customer))
-    # assert_not( user1.roles.include?( role_report ) )
-
-    group_dasa = Group.where(name: 'dasa').first
-    group_raw  = Group.where(name: 'Raw').first
-
-    assert_not(user1.groups_access('full').include?(group_dasa))
-    assert(user1.groups_access('full').include?(group_raw))
-
-    user2 = User.find(3)
-    assert_equal('agent-2 firstname äöüß', user2.firstname)
-    assert_equal('agent-2 lastname äöüß', user2.lastname)
-    assert_equal('agent-2', user2.login)
-    assert_equal('agent-2@example.com', user2.email)
-    assert_equal(true, user2.active)
-
-    assert(user2.roles.include?(role_agent))
-    assert(user2.roles.include?(role_admin))
-    assert_not(user2.roles.include?(role_customer))
-    # assert( user2.roles.include?( role_report ) )
-
-    assert(user2.groups_access('full').include?(group_dasa))
-    assert(user2.groups_access('full').include?(group_raw))
-
-    user3 = User.find(7)
-    assert_equal('invalid', user3.firstname)
-    assert_equal('invalid', user3.lastname)
-    assert_equal('invalid', user3.login)
-    assert_equal('invalid@example.com', user3.email)
-    assert_equal(false, user3.active)
-
-    assert(user3.roles.include?(role_agent))
-    assert_not(user3.roles.include?(role_admin))
-    assert_not(user3.roles.include?(role_customer))
-    # assert( user3.roles.include?( role_report ) )
-
-    assert_not(user3.groups_access('full').include?(group_dasa))
-    assert_not(user3.groups_access('full').include?(group_raw))
-
-    user4 = User.find(8)
-    assert_equal('invalid-temp', user4.firstname)
-    assert_equal('invalid-temp', user4.lastname)
-    assert_equal('invalid-temp', user4.login)
-
-    assert_equal(false, user4.active)
-
-    assert(user4.roles.include?(role_agent))
-    assert_not(user4.roles.include?(role_admin))
-    assert_not(user4.roles.include?(role_customer))
-    # assert( user4.roles.include?( role_report ) )
-
-    assert_not(user4.groups_access('full').include?(group_dasa))
-    assert_not(user4.groups_access('full').include?(group_raw))
-
-  end
-
-  # check all synced states and state types
-  test 'check ticket stats' do
-    state = Ticket::State.find(1)
-    assert_equal('new', state.name)
-    assert_equal('new', state.state_type.name)
-
-    state = Ticket::State.find(2)
-    assert_equal('closed successful', state.name)
-    assert_equal('closed', state.state_type.name)
-
-    state = Ticket::State.find(6)
-    assert_equal('pending reminder', state.name)
-    assert_equal('pending reminder', state.state_type.name)
-  end
-
-  # check groups/queues
-  test 'check groups' do
-    group1 = Group.find(1)
-    assert_equal('Postmaster', group1.name)
-    assert_equal(true, group1.active)
-
-    group2 = Group.find(19)
-    assert_equal('UnitTestQueue20668', group2.name)
-    assert_equal(false, group2.active)
-  end
-
-  # check imported customers and organization relation
-  test 'check customers / organizations' do
-    user1 = User.where(login: 'jn').first
-    assert_equal('Johannes', user1.firstname)
-    assert_equal('Nickel', user1.lastname)
-    assert_equal('jn', user1.login)
-    assert_equal('jn@example.com', user1.email)
-    organization1 = user1.organization
-    assert_equal('Znuny GmbH Berlin', organization1.name)
-    assert_equal('äöüß', organization1.note)
-
-    user2 = User.where(login: 'test90133').first
-    assert_equal('test90133', user2.firstname)
-    assert_equal('test90133', user2.lastname)
-    assert_equal('test90133', user2.login)
-    assert_equal('qa4711@t-online.de', user2.email)
-    organization2 = user2.organization
-    assert(organization2, nil)
-  end
-
-  # check imported tickets
-  test 'check tickets' do
-
-    # ticket is open
-    ticket = Ticket.find(728)
-    assert_equal('test #1', ticket.title)
-    assert_equal('open', ticket.state.name)
-    assert_equal('Misc', ticket.group.name)
-    assert_equal('4 high', ticket.priority.name)
-    assert_equal('agent-2', ticket.owner.login)
-    assert_equal('partner', ticket.customer.login)
-    assert_equal('Partner der betreut', ticket.organization.name)
-    assert_equal(Time.zone.parse('2014-11-20 22:33:41 +0000').gmtime.to_s, ticket.created_at.to_s)
-    assert_nil(ticket.close_at)
-
-    # check history
-    #  - create entry
-
-    # ticket is created with state closed
-    ticket = Ticket.find(729)
-    assert_equal('test #2', ticket.title)
-    assert_equal('closed successful', ticket.state.name)
-    assert_equal('Raw', ticket.group.name)
-    assert_equal('3 normal', ticket.priority.name)
-    assert_equal('agent-2', ticket.owner.login)
-    assert_equal('jn2', ticket.customer.login)
-    assert_equal('Znuny GmbH', ticket.organization.name)
-    assert_equal(Time.zone.parse('2014-11-20 23:24:20 +0000').gmtime.to_s, ticket.created_at.to_s)
-    assert_equal(Time.zone.parse('2014-11-20 23:24:20 +0000').gmtime.to_s, ticket.close_at.to_s)
-
-    # check history
-    #  - create entry
-
-    # ticket is created open and now closed
-    ticket = Ticket.find(730)
-    assert_equal('test #3', ticket.title)
-    assert_equal('closed successful', ticket.state.name)
-    assert_equal('Postmaster', ticket.group.name)
-    assert_equal('3 normal', ticket.priority.name)
-    assert_equal('agent-2', ticket.owner.login)
-    assert_equal('betreuterkunde2', ticket.customer.login)
-    assert_equal('Noch ein betreuter Kunde', ticket.organization.name)
-    assert_equal(Time.zone.parse('2014-11-21 00:17:40 +0000').gmtime.to_s, ticket.created_at.to_s)
-    assert_equal(Time.zone.parse('2014-11-21 00:21:08 +0000').gmtime.to_s, ticket.close_at.to_s)
-
-    # ticket dynamic fields
-    ticket = Ticket.find(591)
-    assert_equal('Some other smart subject!', ticket.title)
-    assert_equal('488', ticket.vertriebsweg)
-    assert_equal(%w[193 194], ticket.te_test)
-    assert_equal('358', ticket.sugar_crm_remote_no)
-    assert_equal('69', ticket.sugar_crm_company_selected_no)
-    assert_equal(['382'], ticket.sugar_crm_company_selection)
-    assert_equal('310', ticket.topic_no)
-    assert_equal('495', ticket.open_exchange_ticket_number)
-    assert_equal('208', ticket.hostname)
-
-    # check history
-    #  - create entry
-    #  - state change entry
-  end
-
-  test 'check article attachments' do
-
-    article = Ticket::Article.find(149)
-    assert_equal(5, article.attachments.count)
-
-    attachment = article.attachments.first
-    assert_equal('image/jpeg', attachment[:preferences]['Mime-Type'])
-    assert_equal('Cursor_und_Banners_and_Alerts_und_Paket-Verwaltung_-_Admin_-_otrs336_und_otrs336.jpg', attachment.filename)
-
-    article = Ticket::Article.find(156)
-    assert_equal(2, article.attachments.count)
-
-    attachment = article.attachments.second
-    assert_equal('application/pdf; name="=?UTF-8?B?5ZSQ6K+X5LiJ55m+6aaWLnBkZg==?="', attachment[:preferences]['Mime-Type'])
-    assert_equal('唐诗三百首.pdf', attachment.filename)
-  end
-
-end