|
210 | 210 | handler.call(request, response) |
211 | 211 | }.to raise_error(not_found_error) |
212 | 212 | end |
| 213 | + |
| 214 | + it "should raise FormatError if tries to fallback and pson serialization is not allowed" do |
| 215 | + Puppet[:allow_pson_serialization] = false |
| 216 | + data = Puppet::IndirectorTesting.new("my data") |
| 217 | + indirection.save(data, "my data") |
| 218 | + request = a_request_that_finds(data, :accept_header => "unknown, text/pson") |
| 219 | + allow(data).to receive(:to_pson).and_raise(Puppet::Network::FormatHandler::FormatError, 'Could not render to Puppet::Network::Format[pson]: source sequence is illegal/malformed utf-8') |
| 220 | + |
| 221 | + expect { |
| 222 | + handler.call(request, response) |
| 223 | + }.to raise_error(Puppet::Network::FormatHandler::FormatError, |
| 224 | + %r{Failed to serialize Puppet::IndirectorTesting for 'my data': Could not render to Puppet::Network::Format\[pson\]}) |
| 225 | + end |
213 | 226 | end |
214 | 227 |
|
215 | 228 | describe "when searching for model instances" do |
|
250 | 263 | %r{No supported formats are acceptable \(Accept: application/json, text/pson\)}) |
251 | 264 | end |
252 | 265 |
|
| 266 | + it "raises FormatError if tries to fallback and pson serialization is not allowed" do |
| 267 | + Puppet[:allow_pson_serialization] = false |
| 268 | + data = Puppet::IndirectorTesting.new("my data") |
| 269 | + indirection.save(data, "my data") |
| 270 | + request = a_request_that_searches(Puppet::IndirectorTesting.new("my"), :accept_header => "unknown, text/pson") |
| 271 | + allow(data).to receive(:to_pson).and_raise(Puppet::Network::FormatHandler::FormatError, 'Could not render to Puppet::Network::Format[pson]: source sequence is illegal/malformed utf-8') |
| 272 | + |
| 273 | + expect { |
| 274 | + handler.call(request, response) |
| 275 | + }.to raise_error(Puppet::Network::FormatHandler::FormatError, |
| 276 | + %r{Failed to serialize Puppet::IndirectorTesting for 'my': Could not render_multiple to Puppet::Network::Format\[pson\]}) |
| 277 | + end |
| 278 | + |
253 | 279 | it "should return [] when searching returns an empty array" do |
254 | 280 | request = a_request_that_searches(Puppet::IndirectorTesting.new("nothing"), :accept_header => "unknown, application/json") |
255 | 281 |
|
|
0 commit comments