Skip to content

Commit

Permalink
if zone-type is forward there is no "file" and "allow-transfer" allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfred Feldmeyer committed Dec 10, 2014
1 parent 28a1ae9 commit 19ebe75
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 19 deletions.
29 changes: 29 additions & 0 deletions spec/defines/dns__zone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,35 @@
with_content(/forward/)
end
end
context 'with a forward zone' do
let :params do
{ :allow_transfer => ['123.123.123.123'],
:allow_forwarder => ['8.8.8.8', '208.67.222.222'],
:forward_policy => 'only',
:zone_type => 'forward'
}
end
it 'should have a type forward entry' do
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/type forward/)
end
it 'should not have allow_tranfer entry' do
should_not contain_concat__fragment('named.conf.local.test.com.include').
with_content(/allow_transfer/)
end
it 'should not have file entry' do
should_not contain_concat__fragment('named.conf.local.test.com.include').
with_content(/file/)
end
it 'should have a forward-policy entry' do
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/forward only/)
end
it 'should have a forwarders entry' do
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/forwarders/)
end
end
end
end

39 changes: 20 additions & 19 deletions templates/zone.erb
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
zone "<%= @zone %>" {
type <%= @zone_type %>;
type <%= @zone_type %>;
<% if @zone_notify -%>
notify <%= @zone_notify %>;
notify <%= @zone_notify %>;
<% end -%>
<% if @zone_type != 'forward' -%>
file "<%= @zone_file %>";
<% end -%>
file "<%= @zone_file %>";
<% if @zone_type == 'slave' -%>
masters { <%= @slave_masters %>;};
masters { <%= @slave_masters %>;};
<% elsif @zone_type == 'master' -%>
<% if @allow_transfer -%>
allow-transfer {
<% @allow_transfer.each do |ip| -%>
<%= ip %>;
<% end -%>
};
<% end -%>
<% if !@allow_forwarder.empty? -%>
forward <%= @forward_policy %>;
forwarders {
<% @allow_forwarder.each do |ip| -%>
<%= ip %>;
<% end -%>
};
<% if @allow_transfer -%>
allow-transfer {
<% @allow_transfer.each do |ip| -%>
<%= ip %>;
<% end -%>
};
<% end -%>
<% end -%>
<% if !@allow_forwarder.empty? and ( @zone_type == 'master' or @zone_type == 'forward') -%>
forward <%= @forward_policy %>;
forwarders {
<% @allow_forwarder.each do |ip| -%>
<%= ip %>;
<% end -%>
};
<% end -%>

};

0 comments on commit 19ebe75

Please sign in to comment.