1 package Support::TestSetup;
6 use CGI qw( -no_xhtml);
15 use SL::InstanceConfiguration;
19 my ($client, $login) = @_;
21 die 'need client and login' unless $client && $login;
25 $::lxdebug = LXDebug->new(target => LXDebug::STDERR_TARGET);
26 $::lxdebug->disable_sub_tracing;
27 $::locale = Locale->new($::lx_office_conf{system}->{language});
29 $::auth = SL::Auth->new;
30 die "Cannot find client with ID or name '$client'" if !$::auth->set_client($client);
32 $::instance_conf = SL::InstanceConfiguration->new;
33 $::request = SL::Request->new( cgi => CGI->new({}), layout => SL::Layout::None->new );
35 die 'cannot reach auth db' unless $::auth->session_tables_present;
37 $::auth->restore_session;
39 require "bin/mozilla/common.pl";
41 die "cannot find user $login" unless %::myconfig = $::auth->read_user(login => $login);
43 $::form->{login} = $login; # normaly implicit at login
45 die "cannot find locale for user $login" unless $::locale = Locale->new($::myconfig{countrycode});
47 $::instance_conf->init;
53 SL::LxOfficeConf->read;
55 my $login = shift || $::lx_office_conf{testing}{login} || 'demo';
56 my $client = shift || $::lx_office_conf{testing}{client} || '';
57 _login($client, $login);
60 sub templates_cache_writable {
61 my $dir = $::lx_office_conf{paths}->{userspath} . '/templates-cache';
64 # Try actually creating a file. Due to ACLs this might be possible
65 # even if the basic Unix permissions and Perl's -w test say
67 my $file = "${dir}/.writetest";
68 my $out = IO::File->new($file, "w") || return 0;