Skip to content

Commit 4e7e233

Browse files
author
Ashley Penney
committed
Update the tests to not test socket on SLES.
1 parent 730d496 commit 4e7e233

File tree

4 files changed

+124
-123
lines changed

4 files changed

+124
-123
lines changed

README.markdown

+7-2
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,16 @@ Retrieves the version of iptables-persistent from your OS. This is a Debian/Ubun
364364

365365
###SLES
366366

367-
The `socket` parameter is not supported on SLES. In this release it will just cause straight iptables failures rather than clean errors.
367+
The `socket` parameter is not supported on SLES. In this release it will cause
368+
the catalog to fail with iptables failures, rather than correctly warn you that
369+
the features are unusable.
368370

369371
###Oracle Linux 5
370372

371-
The `socket` and `owner` parameters are unsupported on Oracle Linux 5, when the "Unbreakable" kernel is used. If you switch to the stock Redhat 5 kernel these work. In this release it will just cause straight iptables failures rather than clean errors.
373+
The `socket` and `owner` parameters are unsupported on Oracle Linux 5, when the
374+
"Unbreakable" kernel is used. If you switch to the stock Redhat 5 kernel these
375+
work. In this release it will cause the catalog to fail with iptables
376+
failures, rather than correct ly warn you that the features are unusable.
372377

373378
###Other
374379

spec/acceptance/firewall_spec.rb

+41-43
Original file line numberDiff line numberDiff line change
@@ -1337,56 +1337,54 @@ class { '::firewall': }
13371337
end
13381338
end
13391339

1340-
# RHEL5 does not support -m socket
1341-
if default['platform'] !~ /el-5/
1342-
describe 'socket' do
1343-
context 'true' do
1344-
it 'applies' do
1345-
pp = <<-EOS
1346-
class { '::firewall': }
1347-
firewall { '585 - test':
1348-
ensure => present,
1349-
proto => tcp,
1350-
port => '585',
1351-
action => accept,
1352-
chain => 'PREROUTING',
1353-
table => 'nat',
1354-
socket => true,
1355-
}
1356-
EOS
1340+
# RHEL5/SLES does not support -m socket
1341+
describe 'socket', :unless => (default['platform'] =~ /el-5/ or fact('operatingsystem') == 'SLES') do
1342+
context 'true' do
1343+
it 'applies' do
1344+
pp = <<-EOS
1345+
class { '::firewall': }
1346+
firewall { '585 - test':
1347+
ensure => present,
1348+
proto => tcp,
1349+
port => '585',
1350+
action => accept,
1351+
chain => 'PREROUTING',
1352+
table => 'nat',
1353+
socket => true,
1354+
}
1355+
EOS
13571356

1358-
apply_manifest(pp, :catch_failures => true)
1359-
end
1357+
apply_manifest(pp, :catch_failures => true)
1358+
end
13601359

1361-
it 'should contain the rule' do
1362-
shell('iptables-save -t nat') do |r|
1363-
expect(r.stdout).to match(/-A PREROUTING -p tcp -m multiport --ports 585 -m socket -m comment --comment "585 - test" -j ACCEPT/)
1364-
end
1360+
it 'should contain the rule' do
1361+
shell('iptables-save -t nat') do |r|
1362+
expect(r.stdout).to match(/-A PREROUTING -p tcp -m multiport --ports 585 -m socket -m comment --comment "585 - test" -j ACCEPT/)
13651363
end
13661364
end
1365+
end
13671366

1368-
context 'false' do
1369-
it 'applies' do
1370-
pp = <<-EOS
1371-
class { '::firewall': }
1372-
firewall { '586 - test':
1373-
ensure => present,
1374-
proto => tcp,
1375-
port => '586',
1376-
action => accept,
1377-
chain => 'PREROUTING',
1378-
table => 'nat',
1379-
socket => false,
1380-
}
1381-
EOS
1367+
context 'false' do
1368+
it 'applies' do
1369+
pp = <<-EOS
1370+
class { '::firewall': }
1371+
firewall { '586 - test':
1372+
ensure => present,
1373+
proto => tcp,
1374+
port => '586',
1375+
action => accept,
1376+
chain => 'PREROUTING',
1377+
table => 'nat',
1378+
socket => false,
1379+
}
1380+
EOS
13821381

1383-
apply_manifest(pp, :catch_failures => true)
1384-
end
1382+
apply_manifest(pp, :catch_failures => true)
1383+
end
13851384

1386-
it 'should contain the rule' do
1387-
shell('iptables-save -t nat') do |r|
1388-
expect(r.stdout).to match(/-A PREROUTING -p tcp -m multiport --ports 586 -m comment --comment "586 - test" -j ACCEPT/)
1389-
end
1385+
it 'should contain the rule' do
1386+
shell('iptables-save -t nat') do |r|
1387+
expect(r.stdout).to match(/-A PREROUTING -p tcp -m multiport --ports 586 -m comment --comment "586 - test" -j ACCEPT/)
13901388
end
13911389
end
13921390
end

spec/acceptance/params_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def pp(params)
2020
pm
2121
end
2222

23-
it 'test various params', :unless => default['platform'].match(/el-5/) do
23+
it 'test various params', :unless => (default['platform'].match(/el-5/) || fact('operatinsystem') == 'SLES') do
2424
iptables_flush_all_tables
2525

2626
ppm = pp({

spec/acceptance/socket_spec.rb

+75-77
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,96 @@
11
require 'spec_helper_acceptance'
22

33
# RHEL5 does not support -m socket
4-
if default['platform'] !~ /el-5/
5-
describe 'firewall socket property' do
6-
before :all do
7-
iptables_flush_all_tables
8-
end
4+
describe 'firewall socket property', :unless => (default['platform'] =~ /el-5/ || fact('operatingsystem') == 'SLES') do
5+
before :all do
6+
iptables_flush_all_tables
7+
end
98

10-
shared_examples "is idempotent" do |value, line_match|
11-
it "changes the value to #{value}" do
12-
pp = <<-EOS
13-
class { '::firewall': }
14-
firewall { '598 - test':
15-
ensure => present,
16-
proto => 'tcp',
17-
chain => 'PREROUTING',
18-
table => 'raw',
19-
#{value}
20-
}
21-
EOS
9+
shared_examples "is idempotent" do |value, line_match|
10+
it "changes the value to #{value}" do
11+
pp = <<-EOS
12+
class { '::firewall': }
13+
firewall { '598 - test':
14+
ensure => present,
15+
proto => 'tcp',
16+
chain => 'PREROUTING',
17+
table => 'raw',
18+
#{value}
19+
}
20+
EOS
2221

23-
apply_manifest(pp, :catch_failures => true)
24-
apply_manifest(pp, :catch_changes => true)
22+
apply_manifest(pp, :catch_failures => true)
23+
apply_manifest(pp, :catch_changes => true)
2524

26-
shell('iptables-save -t raw') do |r|
27-
expect(r.stdout).to match(/#{line_match}/)
28-
end
25+
shell('iptables-save -t raw') do |r|
26+
expect(r.stdout).to match(/#{line_match}/)
2927
end
3028
end
31-
shared_examples "doesn't change" do |value, line_match|
32-
it "doesn't change the value to #{value}" do
33-
pp = <<-EOS
34-
class { '::firewall': }
35-
firewall { '598 - test':
36-
ensure => present,
37-
proto => 'tcp',
38-
chain => 'PREROUTING',
39-
table => 'raw',
40-
#{value}
41-
}
42-
EOS
29+
end
30+
shared_examples "doesn't change" do |value, line_match|
31+
it "doesn't change the value to #{value}" do
32+
pp = <<-EOS
33+
class { '::firewall': }
34+
firewall { '598 - test':
35+
ensure => present,
36+
proto => 'tcp',
37+
chain => 'PREROUTING',
38+
table => 'raw',
39+
#{value}
40+
}
41+
EOS
4342

44-
apply_manifest(pp, :catch_changes => true)
43+
apply_manifest(pp, :catch_changes => true)
4544

46-
shell('iptables-save -t raw') do |r|
47-
expect(r.stdout).to match(/#{line_match}/)
48-
end
45+
shell('iptables-save -t raw') do |r|
46+
expect(r.stdout).to match(/#{line_match}/)
4947
end
5048
end
49+
end
5150

52-
describe 'adding a rule' do
53-
context 'when unset' do
54-
before :all do
55-
iptables_flush_all_tables
56-
end
57-
it_behaves_like 'is idempotent', '', /-A PREROUTING -p tcp -m comment --comment "598 - test"/
51+
describe 'adding a rule' do
52+
context 'when unset' do
53+
before :all do
54+
iptables_flush_all_tables
5855
end
59-
context 'when set to true' do
60-
before :all do
61-
iptables_flush_all_tables
62-
end
63-
it_behaves_like 'is idempotent', 'socket => true,', /-A PREROUTING -p tcp -m socket -m comment --comment "598 - test"/
56+
it_behaves_like 'is idempotent', '', /-A PREROUTING -p tcp -m comment --comment "598 - test"/
57+
end
58+
context 'when set to true' do
59+
before :all do
60+
iptables_flush_all_tables
6461
end
65-
context 'when set to false' do
66-
before :all do
67-
iptables_flush_all_tables
68-
end
69-
it_behaves_like "is idempotent", 'socket => false,', /-A PREROUTING -p tcp -m comment --comment "598 - test"/
62+
it_behaves_like 'is idempotent', 'socket => true,', /-A PREROUTING -p tcp -m socket -m comment --comment "598 - test"/
63+
end
64+
context 'when set to false' do
65+
before :all do
66+
iptables_flush_all_tables
7067
end
68+
it_behaves_like "is idempotent", 'socket => false,', /-A PREROUTING -p tcp -m comment --comment "598 - test"/
7169
end
72-
describe 'editing a rule' do
73-
context 'when unset or false' do
74-
before :each do
75-
iptables_flush_all_tables
76-
shell('iptables -t raw -A PREROUTING -p tcp -m comment --comment "598 - test"')
77-
end
78-
context 'and current value is false' do
79-
it_behaves_like "doesn't change", 'socket => false,', /-A PREROUTING -p tcp -m comment --comment "598 - test"/
80-
end
81-
context 'and current value is true' do
82-
it_behaves_like "is idempotent", 'socket => true,', /-A PREROUTING -p tcp -m socket -m comment --comment "598 - test"/
83-
end
70+
end
71+
describe 'editing a rule' do
72+
context 'when unset or false' do
73+
before :each do
74+
iptables_flush_all_tables
75+
shell('iptables -t raw -A PREROUTING -p tcp -m comment --comment "598 - test"')
76+
end
77+
context 'and current value is false' do
78+
it_behaves_like "doesn't change", 'socket => false,', /-A PREROUTING -p tcp -m comment --comment "598 - test"/
79+
end
80+
context 'and current value is true' do
81+
it_behaves_like "is idempotent", 'socket => true,', /-A PREROUTING -p tcp -m socket -m comment --comment "598 - test"/
82+
end
83+
end
84+
context 'when set to true' do
85+
before :each do
86+
iptables_flush_all_tables
87+
shell('iptables -t raw -A PREROUTING -p tcp -m socket -m comment --comment "598 - test"')
88+
end
89+
context 'and current value is false' do
90+
it_behaves_like "is idempotent", 'socket => false,', /-A PREROUTING -p tcp -m comment --comment "598 - test"/
8491
end
85-
context 'when set to true' do
86-
before :each do
87-
iptables_flush_all_tables
88-
shell('iptables -t raw -A PREROUTING -p tcp -m socket -m comment --comment "598 - test"')
89-
end
90-
context 'and current value is false' do
91-
it_behaves_like "is idempotent", 'socket => false,', /-A PREROUTING -p tcp -m comment --comment "598 - test"/
92-
end
93-
context 'and current value is true' do
94-
it_behaves_like "doesn't change", 'socket => true,', /-A PREROUTING -p tcp -m socket -m comment --comment "598 - test"/
95-
end
92+
context 'and current value is true' do
93+
it_behaves_like "doesn't change", 'socket => true,', /-A PREROUTING -p tcp -m socket -m comment --comment "598 - test"/
9694
end
9795
end
9896
end

0 commit comments

Comments
 (0)