From 94d3a3e92e1d18cb1b9f9b2f85838e3854905966 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 2 Jul 2013 17:21:54 +0200 Subject: [PATCH] =?utf8?q?Auth:=20Support=20f=C3=BCr=20Verbindung=20zur=20?= =?utf8?q?Unit-Test-Datenbank?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Auth.pm | 21 +++++++++++++-------- config/kivitendo.conf.default | 16 +++++++++++----- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/SL/Auth.pm b/SL/Auth.pm index 0e24ef235..00a4b3bbd 100644 --- a/SL/Auth.pm +++ b/SL/Auth.pm @@ -34,12 +34,10 @@ use Rose::Object::MakeMethods::Generic ( sub new { $main::lxdebug->enter_sub(); - my $type = shift; - my $self = {}; + my ($type, %params) = @_; + my $self = bless {}, $type; - bless $self, $type; - - $self->_read_auth_config(); + $self->_read_auth_config(%params); $self->reset; $main::lxdebug->leave_sub(); @@ -50,6 +48,7 @@ sub new { sub reset { my ($self, %params) = @_; + delete $self->{dbh}; $self->{SESSION} = { }; $self->{FULL_RIGHTS} = { }; $self->{RIGHTS} = { }; @@ -100,15 +99,21 @@ sub mini_error { sub _read_auth_config { $main::lxdebug->enter_sub(); - my $self = shift; + my ($self, %params) = @_; map { $self->{$_} = $::lx_office_conf{authentication}->{$_} } keys %{ $::lx_office_conf{authentication} }; # Prevent password leakage to log files when dumping Auth instances. $self->{admin_password} = sub { $::lx_office_conf{authentication}->{admin_password} }; - $self->{DB_config} = $::lx_office_conf{'authentication/database'}; - $self->{LDAP_config} = $::lx_office_conf{'authentication/ldap'}; + if ($params{unit_tests_database}) { + $self->{DB_config} = $::lx_office_conf{'testing/database'}; + $self->{module} = 'DB'; + + } else { + $self->{DB_config} = $::lx_office_conf{'authentication/database'}; + $self->{LDAP_config} = $::lx_office_conf{'authentication/ldap'}; + } if ($self->{module} eq 'DB') { $self->{authenticator} = SL::Auth::DB->new($self); diff --git a/config/kivitendo.conf.default b/config/kivitendo.conf.default index fcc3c49ac..0005aba59 100644 --- a/config/kivitendo.conf.default +++ b/config/kivitendo.conf.default @@ -209,11 +209,17 @@ history_file = users/console_history log_file = /tmp/kivitendo_console_debug.log [testing] -# Automatic login will only work if both "client" and "login" are -# given. "client" can be a client's database ID or its name. "login" -# is simply a user's login name. -client = -login = + +# Several tests need a database they can alter data in freely. This +# database will be dropped & created before any other test is run. The +# following parameters must be given: +[testing/database] +host = localhost +port = 5432 +db = +user = postgres +password = +template = template1 [devel] # Several settings related to the development of kivitendo. -- 2.20.1