Skip to content

Commit

Permalink
Merge pull request #1036 from faker-/MODULES-1784
Browse files Browse the repository at this point in the history
MODULES-1784 check for deprecated options and fail when they are unsupported
  • Loading branch information
Morgan Haskel committed Feb 26, 2015
2 parents ebc549c + 29bc0b3 commit 32ae40b
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 0 deletions.
96 changes: 96 additions & 0 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,14 @@
'provider' => 'files',
'allow' => [ 'from 127.0.0.1', 'from 127.0.0.2', ],
'deny' => [ 'from 127.0.0.3', 'from 127.0.0.4', ],
'satisfy' => 'any',
},
{
'path' => '/var/www/foo',
'provider' => 'files',
'allow' => 'from 127.0.0.5',
'deny' => 'from all',
'order' => 'deny,allow',
},
],

Expand Down Expand Up @@ -442,6 +444,10 @@
:content => /^\s+Deny from 127\.0\.0\.4$/ ) }
it { is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
:content => /^\s+Deny from all$/ ) }
it { is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
:content => /^\s+Satisfy any$/ ) }
it { is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
:content => /^\s+Order deny,allow$/ ) }
it { is_expected.to_not contain_concat__fragment('rspec.example.com-additional_includes') }
it { is_expected.to contain_concat__fragment('rspec.example.com-logging') }
it { is_expected.to contain_concat__fragment('rspec.example.com-serversignature') }
Expand Down Expand Up @@ -751,4 +757,94 @@
it { expect { is_expected.to compile }.to raise_error }
end
end
describe 'allow/deny/order/satisfy deprecation validation' do
let :default_facts do
{
:osfamily => 'RedHat',
:operatingsystemrelease => '6',
:concat_basedir => '/dne',
:operatingsystem => 'RedHat',
:id => 'root',
:kernel => 'Linux',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
}
end
context 'bad allow parameter' do
let :params do
{
'docroot' => '/var/www/files',
'apache_version' => '2.4',
'directories' => {
'path' => '/var/www/files',
'provider' => 'files',
'allow' => 'from 127.0.0.1',
},
}
end
let :facts do default_facts end
it do
expect {
should contain_concat__fragment('rspec.example.com-directories')
}.to raise_error(Puppet::Error)
end
end
context 'bad deny parameter' do
let :params do
{
'docroot' => '/var/www/files',
'apache_version' => '2.4',
'directories' => {
'path' => '/var/www/files',
'provider' => 'files',
'deny' => 'from 127.0.0.1',
},
}
end
let :facts do default_facts end
it do
expect {
should contain_concat__fragment('rspec.example.com-directories')
}.to raise_error(Puppet::Error)
end
end
context 'bad satisfy parameter' do
let :params do
{
'docroot' => '/var/www/files',
'apache_version' => '2.4',
'directories' => {
'path' => '/var/www/files',
'provider' => 'files',
'satisfy' => 'any',
},
}
end
let :facts do default_facts end
it do
expect {
should contain_concat__fragment('rspec.example.com-directories')
}.to raise_error(Puppet::Error)
end
end
context 'bad order parameter' do
let :params do
{
'docroot' => '/var/www/files',
'apache_version' => '2.4',
'directories' => {
'path' => '/var/www/files',
'provider' => 'files',
'order' => 'deny,allow',
},
}
end
let :facts do default_facts end
it do
expect {
should contain_concat__fragment('rspec.example.com-directories')
}.to raise_error(Puppet::Error)
end
end
end
end
14 changes: 14 additions & 0 deletions templates/vhost/_directories.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

## Directories, there should at least be a declaration for <%= @docroot %>
<%- [@_directories].flatten.compact.each do |directory| -%>
<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%>
<%- if directory['allow'] and ! [ false, 'false', '' ].include?(directory['allow']) -%>
<%- scope.function_fail(["Apache::Vhost: Using allow is not supported in your Apache version"]) -%>
<%- end -%>
<%- if directory['deny'] and ! [ false, 'false', '' ].include?(directory['deny']) -%>
<%- scope.function_fail(["Apache::Vhost: Using deny is not supported in your Apache version"]) -%>
<%- end -%>
<%- if directory['order'] and ! [ false, 'false', '' ].include?(directory['order']) -%>
<%- scope.function_fail(["Apache::Vhost: Using order is not supported in your Apache version"]) -%>
<%- end -%>
<%- if directory['satisfy'] and ! [ false, 'false', '' ].include?(directory['satisfy']) -%>
<%- scope.function_fail(["Apache::Vhost: Using satisfy is not supported in your Apache version"]) -%>
<%- end -%>
<%- end -%>
<%- if directory['path'] and directory['path'] != '' -%>
<%- if directory['provider'] and directory['provider'].match('(directory|location|files)') -%>
<%- if /^(.*)match$/ =~ directory['provider'] -%>
Expand Down

0 comments on commit 32ae40b

Please sign in to comment.