db_connection_uri_spec.rb 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. require 'spec_helper'
  2. describe 'puppetdb::server::database', :type => :class do
  3. context 'on a supported platform' do
  4. let(:facts) do
  5. {
  6. :osfamily => 'RedHat',
  7. :operatingsystem => 'RedHat',
  8. :operatingsystemrelease => '7.0',
  9. :fqdn => 'test.domain.local',
  10. }
  11. end
  12. describe 'when setting database_ssl flag' do
  13. let(:params) do
  14. {
  15. 'database_ssl' => true,
  16. }
  17. end
  18. it { should contain_ini_setting('puppetdb_subname').
  19. with(
  20. 'section' => 'database',
  21. 'setting' => 'subname',
  22. 'value' => '//localhost:5432/puppetdb?ssl=true'
  23. )}
  24. end
  25. describe 'when passing jdbc subparams' do
  26. let(:params) do
  27. {
  28. 'jdbc_ssl_properties' => '?ssl=true',
  29. }
  30. end
  31. it { should contain_ini_setting('puppetdb_subname').
  32. with(
  33. 'section' => 'database',
  34. 'setting' => 'subname',
  35. 'value' => '//localhost:5432/puppetdb?ssl=true'
  36. )}
  37. end
  38. describe 'when passing both database_ssl and jdbc subparams' do
  39. let(:params) do
  40. {
  41. 'database_ssl' => true,
  42. 'jdbc_ssl_properties' => '?ssl=true&sslmode=verify-full',
  43. }
  44. end
  45. it { should contain_ini_setting('puppetdb_subname').
  46. with(
  47. 'section' => 'database',
  48. 'setting' => 'subname',
  49. 'value' => '//localhost:5432/puppetdb?ssl=true&sslmode=verify-full'
  50. )}
  51. end
  52. end
  53. end
  54. describe 'puppetdb::server::read_database', :type => :class do
  55. context 'on a supported platform' do
  56. let(:facts) do
  57. {
  58. :osfamily => 'RedHat',
  59. :operatingsystem => 'RedHat',
  60. :operatingsystemrelease => '7.0',
  61. :fqdn => 'test.domain.local',
  62. }
  63. end
  64. describe 'when setting database_ssl flag' do
  65. let(:params) do
  66. {
  67. # this sets read_database_host
  68. 'database_host' => 'localhost',
  69. 'database_ssl' => true,
  70. }
  71. end
  72. it { should contain_ini_setting('puppetdb_read_subname').
  73. with(
  74. 'section' => 'read-database',
  75. 'setting' => 'subname',
  76. 'value' => '//localhost:5432/puppetdb?ssl=true'
  77. )}
  78. end
  79. describe 'when passing jdbc subparams' do
  80. let(:params) do
  81. {
  82. 'database_host' => 'localhost',
  83. 'jdbc_ssl_properties' => '?ssl=true',
  84. }
  85. end
  86. it { should contain_ini_setting('puppetdb_read_subname').
  87. with(
  88. 'section' => 'read-database',
  89. 'setting' => 'subname',
  90. 'value' => '//localhost:5432/puppetdb?ssl=true'
  91. )}
  92. end
  93. describe 'when passing both database_ssl and jdbc subparams' do
  94. let(:params) do
  95. {
  96. 'database_host' => 'localhost',
  97. 'database_ssl' => true,
  98. 'jdbc_ssl_properties' => '?ssl=true&sslmode=verify-full',
  99. }
  100. end
  101. it { should contain_ini_setting('puppetdb_read_subname').
  102. with(
  103. 'section' => 'read-database',
  104. 'setting' => 'subname',
  105. 'value' => '//localhost:5432/puppetdb?ssl=true&sslmode=verify-full'
  106. )}
  107. end
  108. end
  109. end