Debian Codegraph @

tests/t/lib/ProFTPD/Tests/Config/IfModule.pm

raw
1 package ProFTPD::Tests::Config::IfModule;
2
3 use lib qw(t/lib);
4 use base qw(ProFTPD::TestSuite::Child);
5 use strict;
6
7 use File::Spec;
8 use IO::Handle;
9
10 use ProFTPD::TestSuite::FTP;
11 use ProFTPD::TestSuite::Utils qw(:auth :config :running :test :testsuite);
12
13 $| = 1;
14
15 my $order = 0;
16
17 my $TESTS = {
18 ifmodule_close_extra_args => {
19 order => ++$order,
20 test_class => [qw(forking)],
21 },
22
23 };
24
25 sub new {
26 return shift()->SUPER::new(@_);
27 }
28
29 sub list_tests {
30 return testsuite_get_runnable_tests($TESTS);
31 }
32
33 sub ifmodule_close_extra_args {
34 my $self = shift;
35 my $tmpdir = $self->{tmpdir};
36 my $setup = test_setup($tmpdir, 'config');
37
38 my $config = {
39 PidFile => $setup->{pid_file},
40 ScoreboardFile => $setup->{scoreboard_file},
41 SystemLog => $setup->{log_file},
42
43 AuthUserFile => $setup->{auth_user_file},
44 AuthGroupFile => $setup->{auth_group_file},
45 AuthOrder => 'mod_auth_file.c',
46
47 IfModules => {
48 'mod_delay.c' => {
49 DelayEngine => 'off',
50 },
51 },
52 };
53
54 my ($port, $config_user, $config_group) = config_write($setup->{config_file},
55 $config);
56
57 if (open(my $fh, ">> $setup->{config_file}")) {
58 print $fh <<EOC;
59 <IfModule mod_xfer.c>
60 TransferLog /dev/null
61
62 # NOTE: This </IfModule> with the module name should cause the parser to
63 # fail; it is unexpected input.
64 </IfModule mod_xfer.c>
65 EOC
66 unless (close($fh)) {
67 die("Can't write $setup->{config_file}: $!");
68 }
69
70 } else {
71 die("Can't open $setup->{config_file}: $!");
72 }
73
74 my $ex;
75
76 eval { server_start($setup->{config_file}, $setup->{pid_file}) };
77 unless ($@) {
78 $ex = 'Server started up unexpectedly';
79
80 # Allow server to finish starting up
81 sleep(1);
82 eval { server_stop($setup->{pid_file}) };
83
84 test_cleanup($setup->{log_file}, $ex);
85 die($ex);
86 }
87
88 test_cleanup($setup->{log_file}, $ex);
89 }
90
91 1;