-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from traylenator/sendhit
New defined type squid::send_hit
- Loading branch information
Showing
8 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
define squid::send_hit ( | ||
Enum['allow', 'deny'] | ||
$action = 'allow', | ||
String $value = $title, | ||
String $order = '05', | ||
String $comment = "send_hit fragment for ${value}" | ||
) { | ||
|
||
concat::fragment{"squid_send_hit_${value}": | ||
target => $squid::config, | ||
content => template('squid/squid.conf.send_hit.erb'), | ||
order => "21-${order}-${action}", | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require 'spec_helper' | ||
|
||
describe 'squid::send_hit' do | ||
on_supported_os.each do |os, facts| | ||
context "on #{os}" do | ||
let(:facts) do | ||
facts | ||
end | ||
let :pre_condition do | ||
' class{"::squid": | ||
config => "/tmp/squid.conf" | ||
} | ||
' | ||
end | ||
let(:title) { 'myrule' } | ||
|
||
context 'when parameters are unset' do | ||
it { is_expected.to contain_concat_fragment('squid_send_hit_myrule').with_target('/tmp/squid.conf') } | ||
it { is_expected.to contain_concat_fragment('squid_send_hit_myrule').with_order('21-05-allow') } | ||
it { is_expected.to contain_concat_fragment('squid_send_hit_myrule').with_content(%r{^send_hit\s+allow\s+myrule$}) } | ||
it { is_expected.to contain_concat_fragment('squid_send_hit_myrule').with_content(%r{^# send_hit fragment for myrule$}) } | ||
end | ||
context 'when parameters are set' do | ||
let(:params) do | ||
{ | ||
action: 'deny', | ||
value: 'this and that', | ||
order: '03', | ||
comment: 'send_hit this and that' | ||
} | ||
end | ||
|
||
it { is_expected.to contain_concat_fragment('squid_send_hit_this and that').with_target('/tmp/squid.conf') } | ||
it { is_expected.to contain_concat_fragment('squid_send_hit_this and that').with_order('21-03-deny') } | ||
it { is_expected.to contain_concat_fragment('squid_send_hit_this and that').with_content(%r{^send_hit\s+deny\s+this and that$}) } | ||
it { is_expected.to contain_concat_fragment('squid_send_hit_this and that').with_content(%r{^# send_hit this and that$}) } | ||
end | ||
context 'with unknown action' do | ||
let(:params) do | ||
{ | ||
action: 'unknown_action' | ||
} | ||
end | ||
|
||
it { is_expected.to compile.and_raise_error(%r{parameter 'action' expects a match}) } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# <%= @comment %> | ||
send_hit <%= @action %> <%= @value %> | ||
|