From 1d64d7e59fe964edde711f52beeb291e092459ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 26 Oct 2011 14:58:15 +0200 Subject: [PATCH] =?utf8?q?Loginmechanismus=20f=C3=BCr=20Testscripte?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- config/lx_office.conf.default | 5 ++++ t/Support/TestSetup.pm | 52 +++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 t/Support/TestSetup.pm diff --git a/config/lx_office.conf.default b/config/lx_office.conf.default index b0c3e66e5..d84b1c951 100644 --- a/config/lx_office.conf.default +++ b/config/lx_office.conf.default @@ -178,6 +178,11 @@ history_file = users/console_history # to the lx-office log will be put here if triggered from the console log_file = /tmp/lxoffice_console_debug.log +[testing] + +# autologin to use if none is given +login = demo + [debug] # Use DBIx::Log4perl for logging DBI calls. The string LXDEBUGFILE # will be replaced by the file name configured for $::lxdebug. diff --git a/t/Support/TestSetup.pm b/t/Support/TestSetup.pm new file mode 100644 index 000000000..c23b4fd7f --- /dev/null +++ b/t/Support/TestSetup.pm @@ -0,0 +1,52 @@ +package Support::TestSetup; + +use strict; + +use Data::Dumper; +use CGI qw( -no_xhtml); +use SL::Auth; +use SL::Form; +use SL::Locale; +use SL::LXDebug; +use Data::Dumper; +use SL::LxOfficeConf; +use SL::InstanceConfiguration; +SL::LxOfficeConf->read; + +sub _login { + my $login = shift; + + die 'need login' unless $login; + + package main; + + $::lxdebug = LXDebug->new(file => \*STDERR); + $::locale = Locale->new($::lx_office_conf{system}->{language}); + $::form = Form->new; + $::auth = SL::Auth->new; + $::instance_conf = SL::InstanceConfiguration->new; + $::request = { cgi => CGI->new({}) }; + + die 'cannot reach auth db' unless $::auth->session_tables_present; + + $::auth->restore_session; + + require "bin/mozilla/common.pl"; + + die "cannot find user $login" unless %::myconfig = $::auth->read_user($login); + + $::form->{login} = $login; # normaly implicit at login + + die "cannot find locale for user $login" unless $::locale = Locale->new($::myconfig{countrycode}); + + $::instance_conf->init; + + return 1; +} + +sub login { + my $login = shift || $::lx_office_conf{testing}{login} || 'demo'; + _login($login); +} + +1; -- 2.20.1