|
139 | 139 | expect(result[:exception].class.to_s).to eq('OpenSSL::PKey::RSAError') |
140 | 140 | end |
141 | 141 | end |
| 142 | + |
| 143 | + context 'token-based authentication' do |
| 144 | + let(:s_opts) do |
| 145 | + { |
| 146 | + ca_file: OctocatalogDiff::Spec.fixture_path('ssl/generated/ca.crt'), |
| 147 | + client_verify: false, |
| 148 | + url_map: url_map, |
| 149 | + require_header: { 'X-Authentication' => 'my-pdb-token-would-go-here' } |
| 150 | + } |
| 151 | + end |
| 152 | + |
| 153 | + it 'should fail to connect to authenticated puppetdb with no token', retry: 3 do |
| 154 | + opts = { argv: ['-n', 'rspec-node.github.net'], spec_repo: 'tiny-repo' } |
| 155 | + result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts) |
| 156 | + expect(result[:exception].message).to match(/Fact retrieval failed .* from PuppetDB \(403/) |
| 157 | + end |
| 158 | + |
| 159 | + it 'should fail to connect to authenticated puppetdb with an invalid token', retry: 3 do |
| 160 | + args = [ |
| 161 | + '-n', 'rspec-node.github.net', |
| 162 | + '--puppetdb-token', 'my-bogus-token-here', |
| 163 | + '--puppetdb-ssl-ca', OctocatalogDiff::Spec.fixture_path('ssl/generated/ca.crt') |
| 164 | + ] |
| 165 | + opts = { argv: args, spec_repo: 'tiny-repo' } |
| 166 | + result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts) |
| 167 | + expect(result[:exception].message).to match(/Fact retrieval failed .* from PuppetDB \(403/) |
| 168 | + end |
| 169 | + |
| 170 | + it 'should connect to authenticated puppetdb with a token', retry: 3 do |
| 171 | + args = [ |
| 172 | + '-n', 'rspec-node.github.net', |
| 173 | + '--puppetdb-token', 'my-pdb-token-would-go-here', |
| 174 | + '--puppetdb-ssl-ca', OctocatalogDiff::Spec.fixture_path('ssl/generated/ca.crt') |
| 175 | + ] |
| 176 | + opts = { argv: args, spec_repo: 'tiny-repo' } |
| 177 | + result = OctocatalogDiff::Integration.integration_with_puppetdb(s_opts, opts) |
| 178 | + expect(result[:exitcode]).to eq(0), OctocatalogDiff::Integration.format_exception(result) |
| 179 | + end |
| 180 | + end |
142 | 181 | end |
0 commit comments