jetty_ini_spec.rb 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. require 'spec_helper'
  2. describe 'puppetdb::server::jetty', :type => :class do
  3. context 'on a supported platform' do
  4. let(:facts) do
  5. {
  6. :osfamily => 'RedHat',
  7. :fqdn => 'test.domain.local',
  8. }
  9. end
  10. it { should contain_class('puppetdb::server::jetty') }
  11. describe 'when using default values' do
  12. it { should contain_file('/etc/puppetlabs/puppetdb/conf.d/jetty.ini').
  13. with(
  14. 'ensure' => 'file',
  15. 'owner' => 'puppetdb',
  16. 'group' => 'puppetdb',
  17. 'mode' => '0600'
  18. )}
  19. it { should contain_ini_setting('puppetdb_host').
  20. with(
  21. 'ensure' => 'present',
  22. 'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
  23. 'section' => 'jetty',
  24. 'setting' => 'host',
  25. 'value' => 'localhost'
  26. )}
  27. it { should contain_ini_setting('puppetdb_port').
  28. with(
  29. 'ensure' => 'present',
  30. 'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
  31. 'section' => 'jetty',
  32. 'setting' => 'port',
  33. 'value' => 8080
  34. )}
  35. it { should contain_ini_setting('puppetdb_sslhost').
  36. with(
  37. 'ensure' => 'present',
  38. 'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
  39. 'section' => 'jetty',
  40. 'setting' => 'ssl-host',
  41. 'value' => '0.0.0.0'
  42. )}
  43. it { should contain_ini_setting('puppetdb_sslport').
  44. with(
  45. 'ensure' => 'present',
  46. 'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
  47. 'section' => 'jetty',
  48. 'setting' => 'ssl-port',
  49. 'value' => 8081
  50. )}
  51. it { should_not contain_ini_setting('puppetdb_sslprotocols') }
  52. end
  53. describe 'when using a legacy PuppetDB version' do
  54. let (:pre_condition) { 'class { "puppetdb::globals": version => "2.2.0", }' }
  55. it { should contain_ini_setting('puppetdb_host').
  56. with(
  57. 'ensure' => 'present',
  58. 'path' => '/etc/puppetdb/conf.d/jetty.ini',
  59. 'section' => 'jetty',
  60. 'setting' => 'host',
  61. 'value' => 'localhost'
  62. )}
  63. it { should contain_ini_setting('puppetdb_port').
  64. with(
  65. 'ensure' => 'present',
  66. 'path' => '/etc/puppetdb/conf.d/jetty.ini',
  67. 'section' => 'jetty',
  68. 'setting' => 'port',
  69. 'value' => 8080
  70. )}
  71. it { should contain_ini_setting('puppetdb_sslhost').
  72. with(
  73. 'ensure' => 'present',
  74. 'path' => '/etc/puppetdb/conf.d/jetty.ini',
  75. 'section' => 'jetty',
  76. 'setting' => 'ssl-host',
  77. 'value' => '0.0.0.0'
  78. )}
  79. it { should contain_ini_setting('puppetdb_sslport').
  80. with(
  81. 'ensure' => 'present',
  82. 'path' => '/etc/puppetdb/conf.d/jetty.ini',
  83. 'section' => 'jetty',
  84. 'setting' => 'ssl-port',
  85. 'value' => 8081
  86. )}
  87. it { should_not contain_ini_setting('puppetdb_sslprotocols') }
  88. end
  89. describe 'when disabling ssl' do
  90. let(:params) do
  91. {
  92. 'disable_ssl' => true
  93. }
  94. end
  95. it { should contain_ini_setting('puppetdb_host').
  96. with(
  97. 'ensure' => 'present',
  98. 'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
  99. 'section' => 'jetty',
  100. 'setting' => 'host',
  101. 'value' => 'localhost'
  102. )}
  103. it { should contain_ini_setting('puppetdb_port').
  104. with(
  105. 'ensure' => 'present',
  106. 'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
  107. 'section' => 'jetty',
  108. 'setting' => 'port',
  109. 'value' => 8080
  110. )}
  111. it { should contain_ini_setting('puppetdb_sslhost').
  112. with(
  113. 'ensure' => 'absent',
  114. 'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
  115. 'section' => 'jetty',
  116. 'setting' => 'ssl-host'
  117. )}
  118. it { should contain_ini_setting('puppetdb_sslport').
  119. with(
  120. 'ensure' => 'absent',
  121. 'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
  122. 'section' => 'jetty',
  123. 'setting' => 'ssl-port'
  124. )}
  125. end
  126. describe 'when setting max_threads' do
  127. let(:params) do
  128. {
  129. 'max_threads' => 150
  130. }
  131. end
  132. it { should contain_ini_setting('puppetdb_max_threads').
  133. with(
  134. 'ensure' => 'present',
  135. 'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
  136. 'section' => 'jetty',
  137. 'setting' => 'max-threads',
  138. 'value' => '150'
  139. )}
  140. end
  141. describe 'when setting ssl_protocols' do
  142. context 'to a valid string' do
  143. let(:params) { { 'ssl_protocols' => 'TLSv1, TLSv1.1, TLSv1.2' } }
  144. it {
  145. should contain_ini_setting('puppetdb_sslprotocols').with(
  146. 'ensure' => 'present',
  147. 'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
  148. 'section' => 'jetty',
  149. 'setting' => 'ssl-protocols',
  150. 'value' => 'TLSv1, TLSv1.1, TLSv1.2'
  151. )
  152. }
  153. end
  154. context 'to an invalid type (non-string)' do
  155. let(:params) { { 'ssl_protocols' => ['invalid','type'] } }
  156. it 'should fail' do
  157. expect {
  158. should contain_class('puppetdb::server::jetty')
  159. }.to raise_error(Puppet::Error)
  160. end
  161. end
  162. end
  163. describe 'when disabling the cleartext HTTP port' do
  164. let(:params) do
  165. {
  166. 'disable_cleartext' => true
  167. }
  168. end
  169. it { should contain_ini_setting('puppetdb_host').
  170. with(
  171. 'ensure' => 'absent',
  172. 'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
  173. 'section' => 'jetty',
  174. 'setting' => 'host',
  175. 'value' => 'localhost'
  176. )}
  177. it { should contain_ini_setting('puppetdb_port').
  178. with(
  179. 'ensure' => 'absent',
  180. 'path' => '/etc/puppetlabs/puppetdb/conf.d/jetty.ini',
  181. 'section' => 'jetty',
  182. 'setting' => 'port',
  183. 'value' => 8080
  184. )}
  185. end
  186. end
  187. end