Skip to content
This repository has been archived by the owner on Jan 1, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1239 from sensu/hotfix/socket-signature
Browse files Browse the repository at this point in the history
Fix client socket input client signature
  • Loading branch information
portertech committed Apr 25, 2016
2 parents 8f4062a + 325b1a1 commit c0f9394
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/sensu/client/socket.rb
Expand Up @@ -144,8 +144,16 @@ def publish_check_result(check)
:client => @settings[:client][:name],
:check => check.merge(:issued => Time.now.to_i)
}
payload[:signature] = @settings[:client][:signature] if @settings[:client][:signature]
@logger.info("publishing check result", :payload => payload)
@transport.publish(:direct, "results", Sensu::JSON.dump(payload))
@transport.publish(:direct, "results", Sensu::JSON.dump(payload)) do |info|
if info[:error]
@logger.error("failed to publish check result", {
:payload => payload,
:error => info[:error].to_s
})
end
end
end

# Process a check result. Set check result attribute defaults,
Expand Down
13 changes: 13 additions & 0 deletions spec/client/socket_spec.rb
Expand Up @@ -85,6 +85,19 @@
end
subject.publish_check_result(check_result[:check])
end

it "publishes check result with client signature" do
subject.settings[:client][:signature] = "foo"
check_result = result_template
check_result[:signature] = "foo"
expect(logger).to receive(:info).
with("publishing check result", {:payload => check_result})
expect(transport).to receive(:publish).
with(:direct, "results", kind_of(String)) do |_, _, json_string|
expect(Sensu::JSON.load(json_string)).to eq(check_result)
end
subject.publish_check_result(check_result[:check])
end
end

describe "#process_check_result" do
Expand Down

0 comments on commit c0f9394

Please sign in to comment.