Skip to content

Commit 614578a

Browse files
committed
Move Apache 2.2 access parameter to their own test
The previous location was testing it on a vhost that's absent. This is now testing it on the very complex test where it's present. This is important because in the future the whole directories concat fragment isn't rendered on absent vhosts.
1 parent ee2e723 commit 614578a

File tree

1 file changed

+45
-34
lines changed

1 file changed

+45
-34
lines changed

spec/defines/vhost_spec.rb

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,23 +1269,6 @@
12691269
'manage_docroot' => true,
12701270
'logroot' => '/tmp/logroot',
12711271
'logroot_ensure' => 'absent',
1272-
'directories' => [
1273-
{
1274-
'path' => '/var/www/files',
1275-
'provider' => 'files',
1276-
'allow' => ['from 127.0.0.1', 'from 127.0.0.2'],
1277-
'deny' => ['from 127.0.0.3', 'from 127.0.0.4'],
1278-
'satisfy' => 'any',
1279-
},
1280-
{
1281-
'path' => '/var/www/foo',
1282-
'provider' => 'files',
1283-
'allow' => 'from 127.0.0.5',
1284-
'deny' => 'from all',
1285-
'order' => 'deny,allow',
1286-
},
1287-
],
1288-
12891272
}
12901273
end
12911274

@@ -1318,23 +1301,6 @@
13181301
it { is_expected.not_to contain_concat__fragment('rspec.example.com-itk') }
13191302
it { is_expected.not_to contain_concat__fragment('rspec.example.com-fallbackresource') }
13201303
it { is_expected.to contain_concat__fragment('rspec.example.com-directories') }
1321-
# the following style is only present on Apache 2.2
1322-
# That is used in SLES 11, RHEL6, Amazon Linux
1323-
if (facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'].to_i < 7) ||
1324-
(facts[:os]['name'] == 'Amazon') ||
1325-
(facts[:os]['name'] == 'SLES' && facts[:os]['release']['major'].to_i < 12)
1326-
it {
1327-
is_expected.to contain_concat__fragment('rspec.example.com-directories')
1328-
.with_content(%r{^\s+Allow from 127\.0\.0\.1$})
1329-
.with_content(%r{^\s+Allow from 127\.0\.0\.2$})
1330-
.with_content(%r{^\s+Allow from 127\.0\.0\.5$})
1331-
.with_content(%r{^\s+Deny from 127\.0\.0\.3$})
1332-
.with_content(%r{^\s+Deny from 127\.0\.0\.4$})
1333-
.with_content(%r{^\s+Deny from all$})
1334-
.with_content(%r{^\s+Satisfy any$})
1335-
.with_content(%r{^\s+Order deny,allow$})
1336-
}
1337-
end
13381304
it { is_expected.not_to contain_concat__fragment('rspec.example.com-additional_includes') }
13391305
it { is_expected.to contain_concat__fragment('rspec.example.com-logging') }
13401306
it { is_expected.to contain_concat__fragment('rspec.example.com-serversignature') }
@@ -1761,6 +1727,51 @@
17611727
it { is_expected.to contain_concat__fragment('rspec.example.com-directories') }
17621728
end
17631729
end
1730+
1731+
# the following style is only present on Apache 2.2
1732+
# That is used in SLES 11, RHEL6, Amazon Linux
1733+
if (facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'].to_i < 7) ||
1734+
(facts[:os]['name'] == 'Amazon') ||
1735+
(facts[:os]['name'] == 'SLES' && facts[:os]['release']['major'].to_i < 12)
1736+
context 'apache 2.2 access controls on directories' do
1737+
let :params do
1738+
{
1739+
'docroot' => '/var/www/foo',
1740+
'directories' => [
1741+
{
1742+
'path' => '/var/www/foo',
1743+
'provider' => 'files',
1744+
'allow' => 'from 127.0.0.5',
1745+
'deny' => 'from all',
1746+
'order' => 'deny,allow',
1747+
},
1748+
{
1749+
'path' => '/var/www/protected-files',
1750+
'provider' => 'files',
1751+
'allow' => ['from 127.0.0.1', 'from 127.0.0.2'],
1752+
'deny' => ['from 127.0.0.3', 'from 127.0.0.4'],
1753+
'satisfy' => 'any',
1754+
},
1755+
],
1756+
}
1757+
end
1758+
1759+
it { is_expected.to compile }
1760+
it { is_expected.to contain_concat('25-rspec.example.com.conf') }
1761+
it {
1762+
is_expected.to contain_concat__fragment('rspec.example.com-directories')
1763+
.with_content(%r{^\s+Allow from 127\.0\.0\.1$})
1764+
.with_content(%r{^\s+Allow from 127\.0\.0\.2$})
1765+
.with_content(%r{^\s+Allow from 127\.0\.0\.5$})
1766+
.with_content(%r{^\s+Deny from 127\.0\.0\.3$})
1767+
.with_content(%r{^\s+Deny from 127\.0\.0\.4$})
1768+
.with_content(%r{^\s+Deny from all$})
1769+
.with_content(%r{^\s+Satisfy any$})
1770+
.with_content(%r{^\s+Order deny,allow$})
1771+
}
1772+
end
1773+
end
1774+
17641775
context 'require unmanaged' do
17651776
let :params do
17661777
{

0 commit comments

Comments
 (0)