diff --git a/lib/mongo/types/binary.rb b/lib/mongo/types/binary.rb index 9d4577c..a6ad170 100644 --- a/lib/mongo/types/binary.rb +++ b/lib/mongo/types/binary.rb @@ -44,5 +44,9 @@ module Mongo @subtype = subtype end + def inspect + "" + end + end end diff --git a/test/test_binary.rb b/test/test_binary.rb new file mode 100644 index 0000000..b4f6327 --- /dev/null +++ b/test/test_binary.rb @@ -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 "", binary.inspect + end + end +end diff --git a/test/unit/collection_test.rb b/test/unit/collection_test.rb index 98fcdc9..ffdb5b3 100644 --- a/test/unit/collection_test.rb +++ b/test/unit/collection_test.rb @@ -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']