Skip to content

Commit

Permalink
Add validation so both rewrite_www_to_non_www and rewrite_non_www_to_…
Browse files Browse the repository at this point in the history
…www are not set
  • Loading branch information
simmerz committed Jun 10, 2019
1 parent 4b2b108 commit 5ea3bc8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions manifests/resource/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@
fail('You must include the nginx base class before using any defined resources')
}

if $rewrite_www_to_non_www == true and $rewrite_non_www_to_www == true {
fail('You must not set both $rewrite_www_to_non_www and $rewrite_non_www_to_www to true')
}

# Variables
if $nginx::confd_only {
$server_dir = "${nginx::conf_dir}/conf.d"
Expand Down
12 changes: 12 additions & 0 deletions spec/defines/resource_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@
end
end

describe 'with both $rewrite_www_to_non_www and $rewrite_non_www_to_www enabled' do
let(:params) do
default_params.merge(rewrite_non_www_to_www: true, rewrite_www_to_non_www: true)
end

it do
is_expected.to compile.and_raise_error(
%r{You must not set both \$rewrite_www_to_non_www and \$rewrite_non_www_to_www to true}
)
end
end

describe 'server_header template content' do
[
{
Expand Down

0 comments on commit 5ea3bc8

Please sign in to comment.