forked from puppetlabs/puppetlabs-apache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass_spec.rb
82 lines (72 loc) · 2.51 KB
/
class_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
require 'spec_helper_acceptance'
apache_hash = apache_settings_hash
describe 'apache class' do
context 'default parameters' do
let(:pp) { "class { 'apache': }" }
it 'behaves idempotently' do
idempotent_apply(pp)
end
describe 'apache_version fact' do
let(:result) do
apply_manifest('include apache', catch_failures: true)
version_check_pp = <<-MANIFEST
notice("apache_version = >${apache_version}<")
MANIFEST
apply_manifest(version_check_pp, catch_failures: true)
end
it {
expect(result.stdout).to match(%r{apache_version = >#{apache_hash['version']}.*<})
}
end
describe package(apache_hash['package_name']) do
it { is_expected.to be_installed }
end
describe service(apache_hash['service_name']), skip: 'FM-8483' do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
describe port(80) do
it { is_expected.to be_listening }
end
end
context 'custom site/mod dir parameters' do
let(:pp) do
<<-MANIFEST
if $::osfamily == 'RedHat' and "$::selinux" == "true" {
$semanage_package = $::operatingsystemmajrelease ? {
'5' => 'policycoreutils',
default => 'policycoreutils-python',
}
package { $semanage_package: ensure => installed }
exec { 'set_apache_defaults':
command => 'semanage fcontext -a -t httpd_sys_content_t "/apache_spec(/.*)?"',
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
subscribe => Package[$semanage_package],
refreshonly => true,
}
exec { 'restorecon_apache':
command => 'restorecon -Rv /apache_spec',
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
before => Service['httpd'],
require => Class['apache'],
subscribe => Exec['set_apache_defaults'],
refreshonly => true,
}
}
file { '/apache_spec': ensure => directory, }
file { '/apache_spec/apache_custom': ensure => directory, }
class { 'apache':
mod_dir => '/apache_spec/apache_custom/mods',
vhost_dir => '/apache_spec/apache_custom/vhosts',
}
MANIFEST
end
it 'behaves idempotently' do
idempotent_apply(pp)
end
describe service(apache_hash['service_name']), skip: 'FM-8483' do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
end
end