1 use Test::More tests => 8;
11 require 't/common.pl';
13 my $debug = $config{debug};
14 my $stderr = '2>/dev/null';
19 diag("Locally deploying OpenXPKI");
21 # check if infrastructure commands are installed
22 if (system("openxpkiadm >/dev/null 2>&1") != 0) {
23 BAIL_OUT("OpenXPKI deployment environment is not installed");
26 my $instancedir = $config{server_dir};
28 if (length($instancedir) < 10) {
29 BAIL_OUT("Instance directory $instancedir not acceptable.");
32 if (-d $instancedir) {
36 ok(mkpath $instancedir);
39 diag("Deploying ...");
40 ok(system("openxpkiadm deploy --prefix $instancedir $stderr") == 0);
41 # meta config should now exist
42 ok(-e "$config{config_dir}/openxpki.conf");
44 my ($pw_name) = getpwuid($EUID);
45 my ($gr_name) = getgrgid($EUID);
46 my %configure_settings = (
47 'dir.prefix' => File::Spec->rel2abs($instancedir),
48 'dir.dest' => File::Spec->rel2abs($instancedir),
49 'server.socketfile' => File::Spec->rel2abs($config{socket_file}),
50 'server.runuser' => $pw_name,
51 'server.rungroup' => $gr_name,
52 'database.type' => 'SQLite',
53 'database.name' => "$instancedir/var/openxpki/sqlite.db",
56 # configure in this directory
58 ok(chdir $instancedir);
60 my $args = "--batch --createdirs --";
61 foreach my $key (keys %configure_settings) {
62 $args .= " --setcfgvalue $key=$configure_settings{$key}";
64 diag("Configuring ...");
65 ok(system("openxpki-configure $args $stderr") == 0);
71 if (! ok(-e $config{config_file})) {
72 BAIL_OUT("No server configuration file present ($config{config_file})");
75 diag("Initializing database");
76 ok(system("openxpkiadm initdb --config $config{config_file} $stderr") == 0);