forked from puppetlabs/puppetlabs-apache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod_php_spec.rb
95 lines (86 loc) · 2.77 KB
/
mod_php_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
require 'spec_helper_acceptance'
describe 'apache::mod::php class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
case fact('osfamily')
when 'Debian'
vhost_dir = '/etc/apache2/sites-enabled'
mod_dir = '/etc/apache2/mods-available'
service_name = 'apache2'
when 'RedHat'
vhost_dir = '/etc/httpd/conf.d'
mod_dir = '/etc/httpd/conf.d'
service_name = 'httpd'
when 'FreeBSD'
vhost_dir = '/usr/local/etc/apache22/Vhosts'
mod_dir = '/usr/local/etc/apache22/Modules'
service_name = 'apache22'
end
context "default php config" do
it 'succeeds in puppeting php' do
pp= <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
class { 'apache::mod::php': }
apache::vhost { 'php.example.com':
port => '80',
docroot => '/var/www/php',
}
host { 'php.example.com': ip => '127.0.0.1', }
file { '/var/www/php/index.php':
ensure => file,
content => "<?php phpinfo(); ?>\\n",
}
EOS
apply_manifest(pp, :catch_failures => true)
end
describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
describe file("#{mod_dir}/php5.conf") do
it { should contain "DirectoryIndex index.php" }
end
it 'should answer to php.example.com' do
shell("/usr/bin/curl php.example.com:80") do |r|
r.stdout.should =~ /PHP Version/
r.exit_code.should == 0
end
end
end
context "custom php admin_flag and php_admin_value" do
it 'succeeds in puppeting php' do
pp= <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
class { 'apache::mod::php': }
apache::vhost { 'php.example.com':
port => '80',
docroot => '/var/www/php',
php_admin_values => { 'open_basedir' => '/var/www/php/:/usr/share/pear/', },
php_admin_flags => { 'engine' => 'on', },
}
host { 'php.example.com': ip => '127.0.0.1', }
file { '/var/www/php/index.php':
ensure => file,
content => "<?php phpinfo(); ?>\\n",
}
EOS
apply_manifest(pp, :catch_failures => true)
end
describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
describe file("#{vhost_dir}/25-php.example.com.conf") do
it { should contain " php_admin_flag engine on" }
it { should contain " php_admin_value open_basedir /var/www/php/:/usr/share/pear/" }
end
it 'should answer to php.example.com' do
shell("/usr/bin/curl php.example.com:80") do |r|
r.stdout.should =~ /\/usr\/share\/pear\//
r.exit_code.should == 0
end
end
end
end