Revision 39a77adb
Von Moritz Bunkus vor etwa 7 Jahren hinzugefügt
config/kivitendo.conf.default | ||
---|---|---|
256 | 256 |
# database will be dropped & created before any other test is run. The |
257 | 257 |
# following parameters must be given: |
258 | 258 |
[testing/database] |
259 |
host = localhost |
|
260 |
port = 5432 |
|
261 |
db = |
|
262 |
user = postgres |
|
263 |
password = |
|
264 |
template = template1 |
|
259 |
host = localhost |
|
260 |
port = 5432 |
|
261 |
db = |
|
262 |
user = postgres |
|
263 |
password = |
|
264 |
template = template1 |
|
265 |
superuser_user = postgres |
|
266 |
superuser_password = |
|
265 | 267 |
|
266 | 268 |
[devel] |
267 | 269 |
# Several settings related to the development of kivitendo. |
t/000setup_database.t | ||
---|---|---|
16 | 16 |
use SL::LxOfficeConf; |
17 | 17 |
use Support::TestSetup; |
18 | 18 |
|
19 |
our ($db_cfg, $dbh); |
|
19 |
our ($db_cfg, $dbh, $superuser_dbh);
|
|
20 | 20 |
|
21 | 21 |
sub dbg { |
22 | 22 |
# diag(@_); |
... | ... | |
85 | 85 |
|
86 | 86 |
sub report_success { |
87 | 87 |
$dbh->disconnect; |
88 |
$superuser_dbh->disconnect if $superuser_dbh; |
|
88 | 89 |
ok(1, "Database has been setup sucessfully."); |
89 | 90 |
done_testing(); |
90 | 91 |
} |
... | ... | |
97 | 98 |
|
98 | 99 |
dbg("Applying $file"); |
99 | 100 |
|
100 |
my $error = $dbupdater->process_file($dbh, $file, $control); |
|
101 |
my $script_dbh = $control && $control->{superuser_privileges} ? ($superuser_dbh // $dbh) : $dbh; |
|
102 |
my $error = $dbupdater->process_file($script_dbh, $file, $control); |
|
101 | 103 |
|
102 | 104 |
BAIL_OUT("Error applying $file: $error") if $error; |
103 | 105 |
} |
... | ... | |
117 | 119 |
my $dbupdater = SL::DBUpgrade2->new(form => $::form, return_on_error => 1, silent => 1); |
118 | 120 |
my $coa = 'Germany-DATEV-SKR03EU'; |
119 | 121 |
|
122 |
if ($db_cfg->{superuser_user} && ($db_cfg->{superuser_user} ne $db_cfg->{user})) { |
|
123 |
@dbi_options = ( |
|
124 |
'dbi:Pg:dbname=' . $db_cfg->{db} . ';host=' . $db_cfg->{host} . ';port=' . $db_cfg->{port}, |
|
125 |
$db_cfg->{superuser_user}, |
|
126 |
$db_cfg->{superuser_password}, |
|
127 |
SL::DBConnect->get_options(PrintError => 0, PrintWarn => 0), |
|
128 |
); |
|
129 |
|
|
130 |
$superuser_dbh = SL::DBConnect->connect(@dbi_options) || BAIL_OUT("Database superuser connection failed: " . $DBI::errstr); |
|
131 |
} |
|
132 |
|
|
120 | 133 |
apply_dbupgrade($dbupdater, "sql/lx-office.sql"); |
121 | 134 |
apply_dbupgrade($dbupdater, "sql/${coa}-chart.sql"); |
122 | 135 |
|
Auch abrufbar als: Unified diff
Tests: Eigene Verbindungsdaten für DB-Upgrades mit Super-User-Rechten
Wenn der Benutzer, der in der Konfiguration mit `user` & `password`
angegeben ist, keine Super-User-Rechte hat, so kann ein weiterer
Account dafür mit `superuser_user` & `superuser_password` angegeben
werden. Nur diejenigen Datenbankuprade-Scripte, die über den Tag
`@superuser_privileges` signalisieren, dass sie Super-User-Rechte
benötigen, werden auch wirklich mit Super-User-Rechten ausgeführt.