Debian Codegraph @

debian/tests/create-delete

raw symbols SCIP
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use Cwd qw(getcwd);
7 use File::Slurp;
8 use File::stat;
9 use Test::More;
10
11 chdir($ENV{AUTOPKGTEST_TMP}) or die "chdir: $!\n";
12
13 sub assert_present {
14 my ($name) = @_;
15 ok(-d "/home/e-$name");
16 ok(-f "/home/e-$name/ikiwiki.setup");
17 ok(-f "/home/e-$name/public_html/ikiwiki/index.html");
18
19 my $uid = getpwnam("e-$name");
20 my $stat = stat("/home/e-$name");
21 is($stat->uid, $uid);
22 }
23
24 sub assert_absent {
25 my ($name) = @_;
26 ok(! -e "/home/e-$name");
27 }
28
29 # This assumes that ikiwiki-hosting.conf still has prefix_e=example.com.
30 ok(! system(qw(ikisite create foo.example.com --admin=root@localhost)));
31 assert_present('foo');
32
33 my $backup = $ENV{AUTOPKGTEST_TMP}.'/backup';
34
35 ok(! system(qw(ikisite backup), '--filename='.$backup, qw(foo.example.com)));
36 ok(! system(qw(ikisite compact foo.example.com)));
37 ok(! system(qw(ikisite rename foo.example.com baz.example.com)));
38 ok(! system(qw(ikisite restore foo.example.com), '--filename='.$backup));
39 ok(! system(qw(ikisite branch foo.example.com bar.example.com)));
40
41 ok(! system('getent passwd "$(id -nu)" > passwd'));
42 ok(! system('getent group "$(id -ng)" > group'));
43 write_file('hosts', <<EOF);
44 127.0.0.1 foo.example.com
45 EOF
46
47 $ENV{NSS_WRAPPER_PASSWD} = getcwd.'/passwd';
48 $ENV{NSS_WRAPPER_GROUP} = getcwd.'/group';
49 $ENV{NSS_WRAPPER_HOSTS} = getcwd.'/hosts';
50
51 SKIP: {
52 # This only tests systemd, because we can't easily tell the
53 # difference between sysv-rc and a chroot/container with no init
54 # system at all
55 skip('init system not necessarily running', 5) unless -d '/run/systemd/system';
56
57 ok(! system(qw(ikisite changesetup --enable-plugin=branchable --set branchable=1 foo.example.com)));
58 ok(! system(qw(systemctl status ikiwiki-hosting-web.service)));
59
60 {
61 local $ENV{LD_PRELOAD} = 'libnss_wrapper.so';
62 ok(! system(qw(git clone git://foo.example.com/source.git)));
63 }
64
65 ok(! system('find source -name .git -prune -o -print >&2'));
66 ok(-f 'source/.gitignore')
67 };
68
69 ok(! system(qw(ikisite delete foo.example.com)));
70 ok(! system(qw(ikisite delete bar.example.com)));
71 ok(! system(qw(ikisite delete baz.example.com)));
72 assert_absent('foo');
73 assert_absent('bar');
74 assert_absent('baz');
75
76 done_testing;