2013-04-10 00:18:31 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-09-16 00:21:33 +02:00
|
|
|
describe 'puppetdb::server::jetty', :type => :class do
|
2013-04-10 00:18:31 +02:00
|
|
|
context 'on a supported platform' do
|
|
|
|
let(:facts) do
|
|
|
|
{
|
|
|
|
:osfamily => 'RedHat',
|
2013-05-22 01:35:42 +02:00
|
|
|
:fqdn => 'test.domain.local',
|
2013-04-10 00:18:31 +02:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-09-16 00:21:33 +02:00
|
|
|
it { should contain_class('puppetdb::server::jetty') }
|
2013-04-10 00:18:31 +02:00
|
|
|
|
|
|
|
describe 'when using default values' do
|
2016-04-28 13:39:54 +02:00
|
|
|
it { should contain_file('/etc/puppetlabs/puppetdb/conf.d/jetty.ini').
|
|
|
|
with(
|
|
|
|
'ensure' => 'file',
|
|
|
|
'owner' => 'puppetdb',
|
|
|
|
'group' => 'puppetdb',
|
|
|
|
'mode' => '0600'
|
|
|
|
)}
|
2015-06-18 22:45:51 +02:00
|
|
|
it { should contain_ini_setting('puppetdb_host').
|
|
|
|
with(
|
|
|
|
'ensure' => 'present',
|
|
|
|
'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
|
|
|
|
'section' => 'jetty',
|
|
|
|
'setting' => 'host',
|
|
|
|
'value' => 'localhost'
|
|
|
|
)}
|
|
|
|
it { should contain_ini_setting('puppetdb_port').
|
|
|
|
with(
|
|
|
|
'ensure' => 'present',
|
|
|
|
'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
|
|
|
|
'section' => 'jetty',
|
|
|
|
'setting' => 'port',
|
|
|
|
'value' => 8080
|
|
|
|
)}
|
|
|
|
it { should contain_ini_setting('puppetdb_sslhost').
|
|
|
|
with(
|
|
|
|
'ensure' => 'present',
|
|
|
|
'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
|
|
|
|
'section' => 'jetty',
|
|
|
|
'setting' => 'ssl-host',
|
|
|
|
'value' => '0.0.0.0'
|
|
|
|
)}
|
|
|
|
it { should contain_ini_setting('puppetdb_sslport').
|
|
|
|
with(
|
|
|
|
'ensure' => 'present',
|
|
|
|
'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
|
|
|
|
'section' => 'jetty',
|
|
|
|
'setting' => 'ssl-port',
|
|
|
|
'value' => 8081
|
|
|
|
)}
|
|
|
|
it { should_not contain_ini_setting('puppetdb_sslprotocols') }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'when using a legacy PuppetDB version' do
|
|
|
|
let (:pre_condition) { 'class { "puppetdb::globals": version => "2.2.0", }' }
|
2013-04-10 00:18:31 +02:00
|
|
|
it { should contain_ini_setting('puppetdb_host').
|
|
|
|
with(
|
|
|
|
'ensure' => 'present',
|
|
|
|
'path' => '/etc/puppetdb/conf.d/jetty.ini',
|
|
|
|
'section' => 'jetty',
|
|
|
|
'setting' => 'host',
|
2013-04-10 00:51:58 +02:00
|
|
|
'value' => 'localhost'
|
2013-04-10 00:18:31 +02:00
|
|
|
)}
|
|
|
|
it { should contain_ini_setting('puppetdb_port').
|
|
|
|
with(
|
|
|
|
'ensure' => 'present',
|
|
|
|
'path' => '/etc/puppetdb/conf.d/jetty.ini',
|
|
|
|
'section' => 'jetty',
|
|
|
|
'setting' => 'port',
|
2013-04-10 00:51:58 +02:00
|
|
|
'value' => 8080
|
2013-04-10 00:18:31 +02:00
|
|
|
)}
|
|
|
|
it { should contain_ini_setting('puppetdb_sslhost').
|
|
|
|
with(
|
|
|
|
'ensure' => 'present',
|
|
|
|
'path' => '/etc/puppetdb/conf.d/jetty.ini',
|
|
|
|
'section' => 'jetty',
|
|
|
|
'setting' => 'ssl-host',
|
2015-05-29 14:32:02 +02:00
|
|
|
'value' => '0.0.0.0'
|
2013-04-10 00:18:31 +02:00
|
|
|
)}
|
|
|
|
it { should contain_ini_setting('puppetdb_sslport').
|
|
|
|
with(
|
|
|
|
'ensure' => 'present',
|
|
|
|
'path' => '/etc/puppetdb/conf.d/jetty.ini',
|
|
|
|
'section' => 'jetty',
|
|
|
|
'setting' => 'ssl-port',
|
2013-04-10 00:51:58 +02:00
|
|
|
'value' => 8081
|
2013-04-10 00:18:31 +02:00
|
|
|
)}
|
2014-10-17 07:07:45 +02:00
|
|
|
it { should_not contain_ini_setting('puppetdb_sslprotocols') }
|
2013-04-10 00:18:31 +02:00
|
|
|
end
|
2013-04-10 00:31:43 +02:00
|
|
|
|
|
|
|
describe 'when disabling ssl' do
|
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
'disable_ssl' => true
|
|
|
|
}
|
|
|
|
end
|
|
|
|
it { should contain_ini_setting('puppetdb_host').
|
|
|
|
with(
|
|
|
|
'ensure' => 'present',
|
2015-06-18 22:45:51 +02:00
|
|
|
'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
|
2013-04-10 00:31:43 +02:00
|
|
|
'section' => 'jetty',
|
|
|
|
'setting' => 'host',
|
2013-04-10 00:51:58 +02:00
|
|
|
'value' => 'localhost'
|
2013-04-10 00:31:43 +02:00
|
|
|
)}
|
|
|
|
it { should contain_ini_setting('puppetdb_port').
|
|
|
|
with(
|
|
|
|
'ensure' => 'present',
|
2015-06-18 22:45:51 +02:00
|
|
|
'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
|
2013-04-10 00:31:43 +02:00
|
|
|
'section' => 'jetty',
|
|
|
|
'setting' => 'port',
|
2013-04-10 00:51:58 +02:00
|
|
|
'value' => 8080
|
2013-04-10 00:31:43 +02:00
|
|
|
)}
|
|
|
|
it { should contain_ini_setting('puppetdb_sslhost').
|
|
|
|
with(
|
|
|
|
'ensure' => 'absent',
|
2015-06-18 22:45:51 +02:00
|
|
|
'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
|
2013-04-10 00:31:43 +02:00
|
|
|
'section' => 'jetty',
|
2013-04-10 00:51:58 +02:00
|
|
|
'setting' => 'ssl-host'
|
2013-04-10 00:31:43 +02:00
|
|
|
)}
|
|
|
|
it { should contain_ini_setting('puppetdb_sslport').
|
|
|
|
with(
|
|
|
|
'ensure' => 'absent',
|
2015-06-18 22:45:51 +02:00
|
|
|
'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
|
2013-04-10 00:31:43 +02:00
|
|
|
'section' => 'jetty',
|
2013-04-10 00:51:58 +02:00
|
|
|
'setting' => 'ssl-port'
|
2013-04-10 00:31:43 +02:00
|
|
|
)}
|
|
|
|
end
|
2014-06-26 17:15:34 +02:00
|
|
|
|
|
|
|
describe 'when setting max_threads' do
|
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
'max_threads' => 150
|
|
|
|
}
|
|
|
|
end
|
|
|
|
it { should contain_ini_setting('puppetdb_max_threads').
|
|
|
|
with(
|
|
|
|
'ensure' => 'present',
|
2015-06-18 22:45:51 +02:00
|
|
|
'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
|
2014-06-26 17:15:34 +02:00
|
|
|
'section' => 'jetty',
|
|
|
|
'setting' => 'max-threads',
|
|
|
|
'value' => '150'
|
|
|
|
)}
|
|
|
|
end
|
2014-10-17 07:07:45 +02:00
|
|
|
|
|
|
|
describe 'when setting ssl_protocols' do
|
|
|
|
context 'to a valid string' do
|
|
|
|
let(:params) { { 'ssl_protocols' => 'TLSv1, TLSv1.1, TLSv1.2' } }
|
|
|
|
|
|
|
|
it {
|
|
|
|
should contain_ini_setting('puppetdb_sslprotocols').with(
|
|
|
|
'ensure' => 'present',
|
2015-06-18 22:45:51 +02:00
|
|
|
'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
|
2014-10-17 07:07:45 +02:00
|
|
|
'section' => 'jetty',
|
|
|
|
'setting' => 'ssl-protocols',
|
|
|
|
'value' => 'TLSv1, TLSv1.1, TLSv1.2'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'to an invalid type (non-string)' do
|
|
|
|
let(:params) { { 'ssl_protocols' => ['invalid','type'] } }
|
|
|
|
|
|
|
|
it 'should fail' do
|
|
|
|
expect {
|
2015-09-16 00:21:33 +02:00
|
|
|
should contain_class('puppetdb::server::jetty')
|
2014-10-17 07:07:45 +02:00
|
|
|
}.to raise_error(Puppet::Error)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-10-13 19:39:15 +02:00
|
|
|
|
|
|
|
describe 'when disabling the cleartext HTTP port' do
|
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
'disable_cleartext' => true
|
|
|
|
}
|
|
|
|
end
|
|
|
|
it { should contain_ini_setting('puppetdb_host').
|
|
|
|
with(
|
|
|
|
'ensure' => 'absent',
|
|
|
|
'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
|
|
|
|
'section' => 'jetty',
|
|
|
|
'setting' => 'host',
|
|
|
|
'value' => 'localhost'
|
|
|
|
)}
|
|
|
|
it { should contain_ini_setting('puppetdb_port').
|
|
|
|
with(
|
|
|
|
'ensure' => 'absent',
|
|
|
|
'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
|
|
|
|
'section' => 'jetty',
|
|
|
|
'setting' => 'port',
|
|
|
|
'value' => 8080
|
|
|
|
)}
|
|
|
|
end
|
2013-04-10 00:18:31 +02:00
|
|
|
end
|
|
|
|
end
|