not logging binary data RUBY-90

This commit is contained in:
Kyle Banker 2010-02-08 13:48:18 -05:00
parent aad2f5508c
commit a6310a0a4f
3 changed files with 32 additions and 0 deletions

View File

@ -44,5 +44,9 @@ module Mongo
@subtype = subtype
end
def inspect
"<Mongo::Binary:#{object_id}>"
end
end
end

17
test/test_binary.rb Normal file
View File

@ -0,0 +1,17 @@
# encoding:utf-8
require 'test/test_helper'
class BinaryTest < Test::Unit::TestCase
context "Inspecting" do
setup do
@data = ("THIS IS BINARY " * 50).unpack("c*")
end
should "not display actual data" do
binary = Mongo::Binary.new(@data)
assert_equal "<Mongo::Binary:#{binary.object_id}>", binary.inspect
end
end
end

View File

@ -27,6 +27,17 @@ class ConnectionTest < Test::Unit::TestCase
@coll.insert({:title => 'Moby Dick'})
end
should "not log binary data" do
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
@db = @conn['testing']
@coll = @db.collection('books')
data = Mongo::Binary.new(("BINARY " * 1000).unpack("c*"))
@conn.expects(:send_message).with do |op, msg, log|
op == 2002 && log.include?("Mongo::Binary")
end
@coll.insert({:data => data})
end
should "send safe update message" do
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
@db = @conn['testing']