Skip to content

Commit

Permalink
Merge pull request #9480 from joshcooper/http_no_method_error
Browse files Browse the repository at this point in the history
Call the correct ResponseError method
  • Loading branch information
AriaXLi committed Sep 13, 2024
2 parents a1ffb1b + e3b2116 commit e82fe51
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/puppet/ssl/state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def next_state
Wait.new(@machine)
else
to_error(_("Failed to retrieve certificate for %{certname}: %{message}") %
{ certname: Puppet[:certname], message: e.response.message }, e)
{ certname: Puppet[:certname], message: e.message }, e)
end
end
end
Expand Down Expand Up @@ -391,7 +391,7 @@ def next_state
end
Done.new(@machine, @ssl_context)
rescue => e
Puppet.warning(_("Unable to automatically renew certificate: %{message}") % { message: e })
Puppet.warning(_("Unable to automatically renew certificate: %{message}") % { message: e.message })
Done.new(@machine, @ssl_context)
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/unit/ssl/state_machine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,14 @@ def write_csr_attributes(data)
expect(state.next_state).to be_an_instance_of(Puppet::SSL::StateMachine::Wait)
end

it 'transitions to Error if the server returns 500' do
stub_request(:get, %r{puppet-ca/v1/certificate/#{Puppet[:certname]}}).to_return(status: 500)

st = state.next_state
expect(st).to be_an_instance_of(Puppet::SSL::StateMachine::Error)
expect(st.message).to match(/Failed to retrieve certificate/)
end

it "verifies the server's certificate when getting the client cert" do
stub_request(:get, %r{puppet-ca/v1/certificate/#{Puppet[:certname]}}).to_return(status: 200, body: client_cert.to_pem)
allow(cert_provider).to receive(:save_client_cert)
Expand Down

0 comments on commit e82fe51

Please sign in to comment.