1 use Test::More tests => 9;
11 require 't/common.pl';
13 my $debug = $config{debug};
15 diag("Locally deploying OpenXPKI");
17 # check if infrastructure commands are installed
18 if (system("openxpkiadm >/dev/null 2>&1") != 0) {
19 BAIL_OUT("OpenXPKI deployment environment is not installed");
22 my $instancedir = $config{server_dir};
24 if (length($instancedir) < 10) {
25 BAIL_OUT("Instance directory $instancedir not acceptable.");
28 if (-d $instancedir) {
32 ok(mkpath $instancedir);
35 ok(system("openxpkiadm deploy --prefix $instancedir") == 0);
37 # meta config should now exist
38 ok(-e "$config{config_dir}/openxpki.conf");
40 my ($pw_name) = getpwuid($EUID);
41 my ($gr_name) = getgrgid($EUID);
42 my %configure_settings = (
43 'dir.prefix' => File::Spec->rel2abs($instancedir),
44 'server.socketfile' => File::Spec->rel2abs($config{socket_file}),
45 'server.runuser' => $pw_name,
46 'server.rungroup' => $gr_name,
47 'database.type' => 'SQLite',
48 'database.name' => "$instancedir/sqlite.db",
51 # configure in this directory
53 ok(chdir $instancedir);
55 my $args = "--batch --createdirs --";
56 foreach my $key (keys %configure_settings) {
57 $args .= " --setcfgvalue $key=$configure_settings{$key}";
59 diag "Configuring with local options $args";
60 ok(system("openxpki-configure $args") == 0);
65 if (! ok(-e $config{config_file})) {
66 BAIL_OUT("No server configuration file present ($config{config_file})");
69 ok(system("openxpkiadm initdb --config $config{config_file}") == 0);
71 diag "Starting OpenXPKI Server.";
74 # redirect to /dev/null, see OpenXPKI::Tests for the reason (prove hangs)
75 $args = ">/dev/null 2>/dev/null";
76 $args = "--debug 100 --debug OpenXPKI::XML::Config:0 --debug OpenXPKI::XML::Cache:0 >/dev/null 2>/dev/null" if ($debug);
77 if (system("openxpkictl --config $config{config_file} $args start") != 0) {
78 unlink $config{socket_file};
79 BAIL_OUT("Could not start OpenXPKI.");
82 if (! ok(-e $config{socket_file})) {
83 unlink $config{socket_file};
84 BAIL_OUT("Server did not start (no socket file)");