forked from puppetlabs/puppetlabs-apache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod_php_spec.rb
152 lines (140 loc) · 5.04 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
require 'spec_helper_acceptance'
require_relative './version.rb'
unless (fact('operatingsystem') == 'SLES' && fact('operatingsystemrelease') == '12.0')
describe 'apache::mod::php class' do
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 => '#{$doc_root}/php',
}
host { 'php.example.com': ip => '127.0.0.1', }
file { '#{$doc_root}/php/index.php':
ensure => file,
content => "<?php phpinfo(); ?>\\n",
}
EOS
apply_manifest(pp, :catch_failures => true)
end
describe service($service_name) do
if (fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8')
pending 'Should be enabled - Bug 760616 on Debian 8'
else
it { should be_enabled }
end
it { is_expected.to be_running }
end
if (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04')
describe file("#{$mod_dir}/php7.0.conf") do
it { is_expected.to contain "DirectoryIndex index.php" }
end
else
describe file("#{$mod_dir}/php5.conf") do
it { is_expected.to contain "DirectoryIndex index.php" }
end
end
it 'should answer to php.example.com' do
shell("/usr/bin/curl php.example.com:80") do |r|
expect(r.stdout).to match(/PHP Version/)
expect(r.exit_code).to eq(0)
end
end
end
context "custom extensions, php_flag, php_value, 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':
extensions => ['.php','.php5'],
}
apache::vhost { 'php.example.com':
port => '80',
docroot => '#{$doc_root}/php',
php_values => { 'include_path' => '.:/usr/share/pear:/usr/bin/php', },
php_flags => { 'display_errors' => 'on', },
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 { '#{$doc_root}/php/index.php5':
ensure => file,
content => "<?php phpinfo(); ?>\\n",
}
EOS
apply_manifest(pp, :catch_failures => true)
end
describe service($service_name) do
if (fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8')
pending 'Should be enabled - Bug 760616 on Debian 8'
else
it { should be_enabled }
end
it { is_expected.to be_running }
end
describe file("#{$vhost_dir}/25-php.example.com.conf") do
it { is_expected.to contain " php_flag display_errors on" }
it { is_expected.to contain " php_value include_path \".:/usr/share/pear:/usr/bin/php\"" }
it { is_expected.to contain " php_admin_flag engine on" }
it { is_expected.to 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|
expect(r.stdout).to match(/\/usr\/share\/pear\//)
expect(r.exit_code).to eq(0)
end
end
end
context "provide custom config file" do
it 'succeeds in puppeting php' do
pp= <<-EOS
class {'apache':
mpm_module => 'prefork',
}
class {'apache::mod::php':
content => '# somecontent',
}
EOS
apply_manifest(pp, :catch_failures => true)
end
if (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04')
describe file("#{$mod_dir}/php7.0.conf") do
it { should contain "# somecontent" }
end
else
describe file("#{$mod_dir}/php5.conf") do
it { should contain "# somecontent" }
end
end
end
context "provide content and template config file" do
it 'succeeds in puppeting php' do
pp= <<-EOS
class {'apache':
mpm_module => 'prefork',
}
class {'apache::mod::php':
content => '# somecontent',
template => 'apache/mod/php5.conf.erb',
}
EOS
apply_manifest(pp, :catch_failures => true)
end
if (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04')
describe file("#{$mod_dir}/php7.0.conf") do
it { should contain "# somecontent" }
end
else
describe file("#{$mod_dir}/php5.conf") do
it { should contain "# somecontent" }
end
end
end
end
end