X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FTest%2FApache.pm;h=e7e3cdd11cc236244e7d4ad6ecaa2780507396cb;hp=b2733eadb313c547bb2ee52af09e19631835dcf9;hb=7322f2afedcc2f427e997d1535a503613a83f088;hpb=a6fe07e49e3fc12169e801b1ed6874c3a5bd8500 diff --git a/rt/lib/RT/Test/Apache.pm b/rt/lib/RT/Test/Apache.pm index b2733eadb..e7e3cdd11 100644 --- a/rt/lib/RT/Test/Apache.pm +++ b/rt/lib/RT/Test/Apache.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -55,6 +55,10 @@ my %MODULES = ( "mod_perl" => [qw(authz_host env alias perl)], "fastcgi" => [qw(authz_host env alias mime fastcgi)], }, + '2.4' => { + "mod_perl" => [qw(mpm_worker authz_core authn_core authz_host env alias perl)], + "fastcgi" => [qw(mpm_worker authz_core authn_core authz_host env alias mime fastcgi)], + }, ); my $apache_module_prefix = $ENV{RT_TEST_APACHE_MODULES}; @@ -83,6 +87,23 @@ sub basic_auth { EOT } +sub basic_auth_anon { + my $self = shift; + + return <<"EOT"; + AuthType Basic + AuthName "restricted area" + AuthBasicProvider anon + + Anonymous * + Anonymous_NoUserID On + Anonymous_MustGiveEmail Off + Anonymous_VerifyEmail Off + + Require valid-user +EOT +} + sub start_server { my ($self, %config) = @_; my %tmp = %{$config{tmp}}; @@ -108,8 +129,14 @@ sub start_server { rt_sbin_path => $RT::SbinPath, rt_site_config => $ENV{'RT_SITE_CONFIG'}, load_modules => $info{load_modules}, - basic_auth => $config{basic_auth} ? $self->basic_auth : "", ); + if (not $config{basic_auth}) { + $opt{basic_auth} = ""; + } elsif ($config{basic_auth} eq 'anon') { + $opt{basic_auth} = $self->basic_auth_anon; + } else { + $opt{basic_auth} = $self->basic_auth; + } foreach (qw(log pid lock)) { $opt{$_ .'_file'} = File::Spec->catfile( "$tmp{'directory'}", "apache.$_" @@ -169,15 +196,12 @@ sub apache_server_info { RT::Test::diag("Using '$bin' apache executable for testing"); - my $info = `$bin -V`; + my $info = `$bin -v`; ($res{'version'}) = ($info =~ m{Server\s+version:\s+Apache/(\d+\.\d+)\.}); Test::More::BAIL_OUT( "Couldn't figure out version of the server" ) unless $res{'version'}; - my %opts = ($info =~ m/^\s*-D\s+([A-Z_]+?)(?:="(.*)")$/mg); - %res = (%res, %opts); - $res{'modules'} = [ map {s/^\s+//; s/\s+$//; $_} grep $_ !~ /Compiled in modules/i, @@ -193,7 +217,10 @@ sub apache_server_info { ) unless exists $MODULES{$res{version}}{$res{variant}}; my @mlist = @{$MODULES{$res{version}}{$res{variant}}}; - push @mlist, "authn_file", "auth_basic", "authz_user" if $res{basic_auth}; + if ($res{basic_auth}) { + push @mlist, "auth_basic", "authz_user"; + push @mlist, $res{basic_auth} eq 'anon' ? "authn_anon" : "authn_file"; + } $res{'load_modules'} = ''; foreach my $mod ( @mlist ) { @@ -205,6 +232,20 @@ sub apache_server_info { $res{'load_modules'} .= "LoadModule ${mod}_module $so_file\n"; } + + # Apache 2.4 wants to fully-parse a config file when running -V, + # because the MPM is no longer compiled-in. Provide a trivial one. + require File::Temp; + my $tmp = File::Temp->new; + my ($mpm) = grep {/^mpm_/} @{$MODULES{$res{version}}{$res{variant}}}; + print $tmp "LoadModule ${mpm}_module $apache_module_prefix/mod_${mpm}.so\n" + if $mpm; + print $tmp "ErrorLog /dev/null\n"; + print $tmp "TransferLog /dev/null\n"; + close $tmp; + $info = `$res{executable} -V -f $tmp`; + my %opts = ($info =~ m/^\s*-D\s+([A-Z_]+?)(?:="(.*)")$/mg); + %res = (%res, %opts); return %res; } @@ -223,6 +264,7 @@ sub apache_mpm_type { if ( $out =~ /^\s*(worker|prefork|event|itk)\.c\s*$/m ) { return $1; } + return "worker"; } sub fork_exec {