Skip to content

Commit

Permalink
(SIMP-6270) Updating bracketize function (#32)
Browse files Browse the repository at this point in the history
* (SIMP-6270) Updating bracketize function

* fixed bad regex in template, and made test

* updated tests

* Add bug fix note
  • Loading branch information
sharkbruhaha authored Mar 29, 2019
1 parent e7fc9e9 commit 6ff3340
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
* Fri Mar 22 2019 Joseph Sharkey <[email protected]> - 6.1.2-0
- Use simplib::bracketize in lieu of deprecated Puppet 3 bracketize
- Fix template bug that prevented some IPv6 addresses from being
properly formatted in /etc/hosts.allow.

* Tue Mar 19 2019 Liz Nemsick <[email protected]> - 6.1.2-0
- Use simplib::nets2ddq in lieu of deprecated Puppet 3 nets2ddq

Expand Down
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"version_requirement": ">= 2.2.0 < 6.0.0"
},
{
"name": "simp-simplib",
"version_requirement": ">= 3.8.0 < 4.0.0"
"name": "simp/simplib",
"version_requirement": ">= 3.15.0 < 4.0.0"
}
],
"requirements": [
Expand Down
21 changes: 21 additions & 0 deletions spec/defines/allow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@
let(:title) { 'foo_bar' }
let(:params) { {:pattern => 'localhost'} }
it { is_expected.to contain_concat__fragment("tcpwrappers_#{title}") }

context 'with ipv6' do
let(:title) { 'foo_bar' }
let(:params) { { :pattern => '2001:0db8:85a3:0000:0000:8a2e:0370:7334' } }
it { is_expected.to contain_concat__fragment("tcpwrappers_#{title}")\
.with_content(/\[2001:0db8:85a3:0000:0000:8a2e:0370:7334\]/) }
end

context 'with ipv6 cidr' do
let(:title) { 'foo_bar' }
let(:params) { { :pattern => '2001:0db8:85a3:0000:0000:8a2e:0370:7334/64' } }
it { is_expected.to contain_concat__fragment("tcpwrappers_#{title}")\
.with_content(/\[2001:0db8:85a3:0000:0000:8a2e:0370:7334\]\/64/) }
end

context 'with triggered nets2ddq' do
let(:title) { 'foo_bar' }
let(:params) { { :pattern => 'localhost myhost 129.3.0.1 2001:0db8:85a3:0000:0000:8a2e:0370:7334 2001:0db8:85a3:0000:0000:8a2e:0370:7334/64 234.216.15.14/16' } }
it { is_expected.to contain_concat__fragment("tcpwrappers_#{title}")\
.with_content(/localhost,myhost,129.3.0.1,\[2001:0db8:85a3:0000:0000:8a2e:0370:7334\],\[2001:0db8:85a3:0000:0000:8a2e:0370:7334\]\/64,234.216.0.0\/255.255.0.0/) }
end
end
end
end
Expand Down
7 changes: 1 addition & 6 deletions templates/tcpwrappers.allow.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<%

lpattern = Array.new

Array(@pattern).flatten.each do |ptn|
if ptn == 'any'
lpattern.push('ALL')
elsif ptn !~ /[[:alpha:]]/
lpattern.push(scope.function_bracketize([scope.call_function('simplib::nets2ddq', [ptn])]))
else
lpattern.push(ptn)
lpattern.push(scope.call_function('simplib::bracketize',[scope.call_function('simplib::nets2ddq', [ptn])]))
end
end

if @svc
_name = @svc
else
Expand Down

0 comments on commit 6ff3340

Please sign in to comment.