not logging binary data RUBY-90
This commit is contained in:
parent
aad2f5508c
commit
a6310a0a4f
|
@ -44,5 +44,9 @@ module Mongo
|
||||||
@subtype = subtype
|
@subtype = subtype
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def inspect
|
||||||
|
"<Mongo::Binary:#{object_id}>"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
|
@ -27,6 +27,17 @@ class ConnectionTest < Test::Unit::TestCase
|
||||||
@coll.insert({:title => 'Moby Dick'})
|
@coll.insert({:title => 'Moby Dick'})
|
||||||
end
|
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
|
should "send safe update message" do
|
||||||
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
|
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
|
||||||
@db = @conn['testing']
|
@db = @conn['testing']
|
||||||
|
|
Loading…
Reference in New Issue