4 use Test
::More tests
=> 20;
6 BEGIN { use_ok
("IkiWiki"); }
7 BEGIN { use_ok
("IkiWiki::Render"); }
9 %config=IkiWiki
::defaultconfig
();
10 $config{srcdir
}="t/tmp/srcdir";
11 $config{underlaydir
}="t/tmp/underlaydir";
12 IkiWiki
::checkconfig
();
15 ok
(! system("rm -rf t/tmp"));
19 foreach my $file (@_) {
20 writefile
($file, $config{underlaydir
}, "test content");
26 foreach my $file (@_) {
27 writefile
($file, $config{srcdir
}, "test content");
33 my %expected=map { $_ => 1 } @
{shift()}; # the input list may have dups
36 close STDERR
; # find_src_files prints warnings about bad files
38 my ($files, $pages)=IkiWiki
::find_src_files
();
39 is_deeply
([sort @
$files], [sort keys %expected], $desc);
44 my @list=setup_underlay
(qw{index.mdwn sandbox
.mdwn smiley
.png ikiwiki
.mdwn ikiwiki
/directive.mdwn ikiwiki/directive
/foo
.mdwn
});
45 push @list, setup_srcdir
(qw{index.mdwn foo
.mwdn icon
.jpeg blog
/archive/1/2/3/foo.mdwn blog/archive
/1/2/4/bar
.mdwn blog
/archive
.mdwn
});
46 test_src_files
(\
@list, "simple test");
48 setup_srcdir
(".badfile");
49 test_src_files
(\
@list, "srcdir dotfile is skipped");
51 setup_underlay
(".badfile");
52 test_src_files
(\
@list, "underlay dotfile is skipped");
54 setup_srcdir
(".ikiwiki/index");
55 test_src_files
(\
@list, "srcdir dotdir is skipped");
57 setup_underlay
(".ikiwiki/index");
58 test_src_files
(\
@list, "underlay dotdir is skipped");
60 setup_srcdir
("foo>.mdwn");
61 test_src_files
(\
@list, "illegal srcdir filename skipped");
63 setup_underlay
("foo>.mdwn");
64 test_src_files
(\
@list, "illegal underlay filename skipped");
66 system("mkdir -p $config{srcdir}/empty");
67 test_src_files
(\
@list, "empty srcdir directory ignored");
69 system("mkdir -p $config{underlaydir}/empty");
70 test_src_files
(\
@list, "empty underlay directory ignored");
72 setup_underlay
("bad.mdwn");
73 system("ln -sf /etc/passwd $config{srcdir}/bad.mdwn");
74 test_src_files
(\
@list, "underlaydir override attack foiled");
76 system("ln -sf /etc/passwd $config{srcdir}/symlink.mdwn");
77 test_src_files
(\
@list, "file symlink in srcdir skipped");
79 system("ln -sf /etc/passwd $config{underlaydir}/symlink.mdwn");
80 test_src_files
(\
@list, "file symlink in underlaydir skipped");
82 system("ln -sf /etc/ $config{srcdir}/symdir");
83 test_src_files
(\
@list, "dir symlink in srcdir skipped");
85 system("ln -sf /etc/ $config{underlaydir}/symdir");
86 test_src_files
(\
@list, "dir symlink in underlaydir skipped");
88 system("ln -sf /etc/ $config{srcdir}/blog/symdir");
89 test_src_files
(\
@list, "deep dir symlink in srcdir skipped");
91 system("ln -sf /etc/ $config{underlaydir}/ikiwiki/symdir");
92 test_src_files
(\
@list, "deep dir symlink in underlaydir skipped");