|
103 | 103 | .with_auth_option("map=#{identity_map} clientcert=1")
|
104 | 104 | end
|
105 | 105 |
|
106 |
| - it 'has hba rule for puppetdb-read user ipv4' do |
107 |
| - is_expected.to contain_postgresql__server__pg_hba_rule("Allow certificate mapped connections to #{params[:database_name]} as #{params[:read_database_username]} (ipv4)") |
108 |
| - .with_type('hostssl') |
109 |
| - .with_database(params[:database_name]) |
110 |
| - .with_user(params[:read_database_username]) |
111 |
| - .with_address('0.0.0.0/0') |
112 |
| - .with_auth_method('cert') |
113 |
| - .with_order(0) |
114 |
| - .with_auth_option("map=#{read_identity_map} clientcert=1") |
| 106 | + it 'does not create hba rule for puppetdb-read user ipv4' do |
| 107 | + is_expected.not_to contain_postgresql__server__pg_hba_rule("Allow certificate mapped connections to #{params[:database_name]} as #{params[:read_database_username]} (ipv4)") |
115 | 108 | end
|
116 | 109 |
|
117 | 110 | it 'has hba rule for puppetdb user ipv6' do
|
|
125 | 118 | .with_auth_option("map=#{identity_map} clientcert=1")
|
126 | 119 | end
|
127 | 120 |
|
128 |
| - it 'has hba rule for puppetdb-read user ipv6' do |
129 |
| - is_expected.to contain_postgresql__server__pg_hba_rule("Allow certificate mapped connections to #{params[:database_name]} as #{params[:read_database_username]} (ipv6)") |
130 |
| - .with_type('hostssl') |
131 |
| - .with_database(params[:database_name]) |
132 |
| - .with_user(params[:read_database_username]) |
133 |
| - .with_address('::0/0') |
134 |
| - .with_auth_method('cert') |
135 |
| - .with_order(0) |
136 |
| - .with_auth_option("map=#{read_identity_map} clientcert=1") |
| 121 | + it 'does not create hba rule for puppetdb-read user ipv6' do |
| 122 | + is_expected.not_to contain_postgresql__server__pg_hba_rule("Allow certificate mapped connections to #{params[:database_name]} as #{params[:read_database_username]} (ipv6)") |
137 | 123 | end
|
138 | 124 |
|
139 | 125 | it 'has ident rule' do
|
|
143 | 129 | .with_database_username(params[:database_name])
|
144 | 130 | end
|
145 | 131 |
|
146 |
| - it 'has read ident rule' do |
147 |
| - is_expected.to contain_postgresql__server__pg_ident_rule("Map the SSL certificate of the server as a #{params[:read_database_username]} user") |
148 |
| - .with_map_name(read_identity_map) |
149 |
| - .with_system_username(facts[:fqdn]) |
150 |
| - .with_database_username(params[:read_database_username]) |
| 132 | + it 'does not create read ident rule' do |
| 133 | + is_expected.not_to contain_postgresql__server__pg_ident_rule("Map the SSL certificate of the server as a #{params[:read_database_username]} user") |
151 | 134 | end
|
152 | 135 |
|
153 | 136 | context 'when the puppetdb_server is set' do
|
|
166 | 149 | .with_database_username(params[:database_name])
|
167 | 150 | end
|
168 | 151 | end
|
| 152 | + |
| 153 | + context 'when the create_read_user_rule is set to true' do |
| 154 | + let(:params) do |
| 155 | + { |
| 156 | + database_name: 'puppetdb', |
| 157 | + read_database_username: 'puppetdb-read', |
| 158 | + create_read_user_rule: true, |
| 159 | + } |
| 160 | + end |
| 161 | + |
| 162 | + it 'has hba rule for puppetdb-read user ipv4' do |
| 163 | + is_expected.to contain_postgresql__server__pg_hba_rule("Allow certificate mapped connections to #{params[:database_name]} as #{params[:read_database_username]} (ipv4)") |
| 164 | + .with_type('hostssl') |
| 165 | + .with_database(params[:database_name]) |
| 166 | + .with_user(params[:read_database_username]) |
| 167 | + .with_address('0.0.0.0/0') |
| 168 | + .with_auth_method('cert') |
| 169 | + .with_order(0) |
| 170 | + .with_auth_option("map=#{read_identity_map} clientcert=1") |
| 171 | + end |
| 172 | + |
| 173 | + it 'has hba rule for puppetdb-read user ipv6' do |
| 174 | + is_expected.to contain_postgresql__server__pg_hba_rule("Allow certificate mapped connections to #{params[:database_name]} as #{params[:read_database_username]} (ipv6)") |
| 175 | + .with_type('hostssl') |
| 176 | + .with_database(params[:database_name]) |
| 177 | + .with_user(params[:read_database_username]) |
| 178 | + .with_address('::0/0') |
| 179 | + .with_auth_method('cert') |
| 180 | + .with_order(0) |
| 181 | + .with_auth_option("map=#{read_identity_map} clientcert=1") |
| 182 | + end |
| 183 | + |
| 184 | + it 'has read ident rule' do |
| 185 | + is_expected.to contain_postgresql__server__pg_ident_rule("Map the SSL certificate of the server as a #{params[:read_database_username]} user") |
| 186 | + .with_map_name(read_identity_map) |
| 187 | + .with_system_username(facts[:fqdn]) |
| 188 | + .with_database_username(params[:read_database_username]) |
| 189 | + end |
| 190 | + end |
169 | 191 | end
|
170 | 192 | end
|
0 commit comments